Simple Example Please

Nov 18, 2009 at 6:04 PM

I have perused the PasswordSafe example extensively, but it's rather complex. Could someone do a simple write up for a hello world style simple Fluid list. I tried this...

            FluidPanel mainPanel = new FluidPanel(0, 0, 200, 200);
            mainPanel.BackColor = Color.Red;

            BindingList<object> source = new BindingList<object>();
            source.Add("one");
            source.Add("two");
            source.Add("three");
            fluidHost1.Bounds = this.ClientRectangle;
            FluidListBox flb = new FluidListBox();
            flb.DataSource = source;
            textBox1.Text += flb.ItemCount.ToString() + Environment.NewLine;
            flb.BorderColor = Color.Blue;
            mainPanel.Controls.Add(flb);
            fluidHost1.Add(mainPanel);

...but it's not working. I can see a red panel (my mainPanel) but I don't get a list. Thanks. 

Nov 24, 2009 at 12:23 PM

Your Sample can't work, because you added a list to a textbox control :-) the control trys his best, but the result is not that want you want to expected.

 I'm not sure what you are looking for, but here is a short "hello world" sample

            //Main Panel
            FluidPanel mainPanel = new FluidPanel();
            mainPanel.Bounds = new Rectangle(0, 0, 240, 300);
            mainPanel.BackColor = Color.Red;
            mainPanel.GradientFill = true;
            mainPanel.GradientFillOffset = 30;
            mainPanel.ForeColor = Color.White;
            mainPanel.ShowMaximized();
            fluidHost.Add(mainPanel);

            //Label
            FluidLabel h1 = new FluidLabel("Hello World", 0, 0, 240, 40);
            h1.ShadowColor = Color.Black;
            h1.ForeColor = Color.White;
            h1.Alignment = StringAlignment.Center;
            h1.LineAlignment = StringAlignment.Center;
            h1.Font = new Font(FontFamily.GenericSansSerif, 12f, FontStyle.Bold);
            h1.Anchor = FluidControl.AnchorTLR;
            fluidHost.Add(h1);

            //
            FluidButton okBtn = new FluidButton("OK", 70, 300 - 40, 100, 32);
            okBtn.BackColor = Color.Black;
            okBtn.Click += new EventHandler(okBtn_Click);
            okBtn.ForeColor = Color.White;
            okBtn.Anchor = FluidControl.AnchorBL;
            fluidHost.Add(okBtn);

 

 

Nov 24, 2009 at 3:30 PM

Thanks, jdaehler. The spot in my code where it looks like I'm setting a Textbox to a FluidList is actually just a little debug code where I'm just displaying the number of items in the list. I was adding 3 items to the list and seeing that there were 3 items, but then not seeing anything show up on the screen. Turns out I just had to give the panel some bounds and then it showed up.

Thanks also for the example. That a good hello world app just like I requested. I guess I'm more interested in the FluidList control though. I got it working on my own recently, but I am having another issue. I'll post it in a new discussion since it's a new topic.

Thanks again for your help!

Feb 2, 2010 at 8:41 AM

Where is fluidHost define? I not fount fluidHost.

I will use "Controls.Add"

 

Mar 26, 2010 at 11:36 PM

Here are the definitions:

 

PasswordForm.Designer.cs

private void InitializeComponent()
        {
            this.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.Host = new Fluid.Controls.FluidHost();

            .....

 

Host.cs

namespace Fluid.Controls
{
    /// <summary>
    /// A windows control that represents a host for a fluid control.
    /// The host also provides gesture, mouse and keyboard events.
    /// </summary>
    public partial class FluidHost : Control, IContainer, ICommandContainer, IHost

    ......