hi all
I want to genrate a control corssponding to each checked items of checklist box control. will you help me .
thanks in advance.

Recommended Answers

All 6 Replies

Hi
do u want to generate control corresponding to each checked items of checklist? For example if u tick TextBox in checklist, then u need to Generate TextBox?

[INDENT]TextBox text = new TextBox();
text.Location = new Point(100, 100);
this.Controls.Add(text);[/INDENT]

This will create TextBox Dynamically

Hi
do u want to generate control corresponding to each checked items of checklist? For example if u tick TextBox in checklist, then u need to Generate TextBox?

[INDENT]TextBox text = new TextBox();
text.Location = new Point(100, 100);
this.Controls.Add(text);[/INDENT]

This will create TextBox Dynamically

thanks frd,
but i want to generate control corresponding to eact checked items while i checked items previously, means prob is how to identify which item is selected and and for whom new control is genrate.

Hi friend,
Specify what control u used for Check List. (List Box, CheckBoxes ...)?

Hi friend,
Specify what control u used for Check List. (List Box, CheckBoxes ...)?

hi frd
i want to genrate panel control
thanks for your attention..

Hi,
U use Panel for Checklist ? How i dont know ? But i give an Example Using ListBox

> Draw a ListBox (listBox1)
> Draw a Button (button1)

Try this code

int iLastY;
        private void Form1_Load(object sender, EventArgs e)
        {
            listBox1.Items.Add("TextBox");
            listBox1.Items.Add("ListBox");
            listBox1.Items.Add("Button");
            iLastY = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Control ctrl = null;
            switch (listBox1.SelectedIndex)
            {
                case 0: //TextBox
                    ctrl = new TextBox();
                    break;
                case 1: //ListBox
                    ctrl = new ListBox ();
                    break;
                case 2: //Button
                    ctrl = new Button();
                    break;
            }

            if (ctrl != null)
            {
                ctrl.Left = 100;
                ctrl.Top = iLastY;
                this.Controls.Add(ctrl);
                iLastY = ctrl.Bottom;
            }
        }

Thank you
I got idia from this code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.