Jim Dunham6 reputationPosted Feb 2, 2010, 4:47 AM EST
0
Not exactly sure what you are trying to do, however you are overwriting your original control added in the formload. Then you are overwriting one textbox (named chkbox) with the other. Use this code in your function and you'll see what I mean. I THINK you are not trying to overwrite the this.chkbox. TextBox chkBox = new TextBox(); // Is this a checkbox or textbox?? chkBox.Text = "Disable"; // the this chkbox or the one created in this function? chkBox.Location = new System.Drawing.Point(152 + (i*10) + 10, 192 + (i*10) + 20); chkBox.Size = new System.Drawing.Size(110, 30); chkBox.BackColor = System.Drawing.Color.Aqua; if (i == 1) chkBox.BackColor = System.Drawing.Color.Red; Controls.Add(chkBox);//MessageBox.Show("hello kiran how are you");
Jim Dunham6 reputationPosted Feb 2, 2010, 6:24 AM EST
0
Did you try the code here? This way you can see the behavior and understand what is going on.
TextBox chkBox = new TextBox(); // Is this a checkbox or textbox?? chkBox.Text = "Disable"; // the this chkbox or the one created in this function? chkBox.Location = new System.Drawing.Point(152 + (i*10) + 10, 192 + (i*10) + 20); chkBox.Size = new System.Drawing.Size(110, 30); chkBox.BackColor = System.Drawing.Color.Aqua; if (i == 1) chkBox.BackColor = System.Drawing.Color.Red; Controls.Add(chkBox);//MessageBox.Show("hello kiran how are you");
Jim Dunham6 reputationPosted Feb 2, 2010, 4:47 AM EST
TextBox chkBox = new TextBox(); // Is this a checkbox or textbox??
chkBox.Text = "Disable"; // the this chkbox or the one created in this function?
chkBox.Location = new System.Drawing.Point(152 + (i*10) + 10, 192 + (i*10) + 20);
chkBox.Size = new System.Drawing.Size(110, 30);
chkBox.BackColor = System.Drawing.Color.Aqua;
if (i == 1)
chkBox.BackColor = System.Drawing.Color.Red;
Controls.Add(chkBox);//MessageBox.Show("hello kiran how are you");
kiran kumarRank #3,110 · 461 reputationPosted Feb 2, 2010, 4:56 AM EST
Jim Dunham6 reputationPosted Feb 2, 2010, 6:24 AM EST
TextBox chkBox = new TextBox(); // Is this a checkbox or textbox??
chkBox.Text = "Disable"; // the this chkbox or the one created in this function?
chkBox.Location = new System.Drawing.Point(152 + (i*10) + 10, 192 + (i*10) + 20);
chkBox.Size = new System.Drawing.Size(110, 30);
chkBox.BackColor = System.Drawing.Color.Aqua;
if (i == 1)
chkBox.BackColor = System.Drawing.Color.Red;
Controls.Add(chkBox);//MessageBox.Show("hello kiran how are you");