Creating Instance of button at run time.
-
Dear All Hi,I am new to csharp, I want to create a Bar Graph without using the graphics class, I want to use a button and adjust its size so that it looks like a bar.I will populate the properties of the buttons (size,color,position) at the run time. I need to create button instances at run time, I tried creating user objects of the button, but still I am unable to create many buttons at runtime. Any help or ideas will be appreciated . Thanks
-
Dear All Hi,I am new to csharp, I want to create a Bar Graph without using the graphics class, I want to use a button and adjust its size so that it looks like a bar.I will populate the properties of the buttons (size,color,position) at the run time. I need to create button instances at run time, I tried creating user objects of the button, but still I am unable to create many buttons at runtime. Any help or ideas will be appreciated . Thanks
-
Hi Greeg, If I had to create 100 buttons ,I do not want to write this code 100 times. I want something which is like cloning or creating Instances, for a user object button.Its not clear to me how we can do it in csharp.
-
Hi Greeg, If I had to create 100 buttons ,I do not want to write this code 100 times. I want something which is like cloning or creating Instances, for a user object button.Its not clear to me how we can do it in csharp.
Buy a book int left = 0; int space = 1; //pix for ( int i = 0 ; i < nbButtons ; i++) { Button b = new Button(); b.name = i.ToString(); b.Text = i.ToString(); b.Left = left; c.Controls.Add (b); //C is a user control left += b.Left + b.Width + space; }
-
Buy a book int left = 0; int space = 1; //pix for ( int i = 0 ; i < nbButtons ; i++) { Button b = new Button(); b.name = i.ToString(); b.Text = i.ToString(); b.Left = left; c.Controls.Add (b); //C is a user control left += b.Left + b.Width + space; }
Thanks Lisan I'll get some good books but until then this works. int left = 0; int space = 1; //pix int nbButtons = 5; for (int i = 0; i < nbButtons; i++) { GlassButton gb = new GlassButton(); gb.Name = i.ToString(); gb.Text = i.ToString(); gb.Left = left; gb.Location = new Point(20 + (i*5) , 10 + (i *5) ); this.Controls.Add(gb); //gb is a user control left += gb.Left + gb.Width + space; } Thanks again