hi ,
I wish to create buttons(kinda array of buttons) on a form everytime the form loads.
I am not getting the code/syntaxes for the same.
Its like that the no buttons and there attribute on the form changes dynamically according to the DB .
Please some1 help me with this, m new, and this is my Software engineering course, m really challenged right now, guys please help.

I wish to create buttons(kinda array of buttons) on a form everytime the form loads.
I am not getting the code/syntaxes for the same.
Its like that the number of buttons and there attribute on the form changes dynamically according to the DB .
Please some1 help me with this, m new, and this is my Software engineering course, m really challenged right now, guys please help

Make a windows form application, drop a button on it from the toolbox and see what code is generated in the XXX.designer.cs file. Should give you a start. This is the way I did it to find out some things. Succes!

Make a windows form application, drop a button on it from the toolbox and see what code is generated in the XXX.designer.cs file. Should give you a start. This is the way I did it to find out some things. Succes!

Yeah its kinda helping...
but where to put this new code

this.btn1 = new System.Windows.Forms.Button();
this.btn1.BackColor = System.Drawing.Color.Turquoise;
this.btn1.Location = new System.Drawing.Point(24, 201);
this.btn1.Name = "btn1";
this.btn1.Size = new System.Drawing.Size(60, 30);
this.btn1.TabIndex = 0;
this.btn1.Text = "# 1";
this.btn1.UseVisualStyleBackColor = false;
this.btn1.Click += new System.EventHandler(this.btn1_Click);

shud i put in the new form...
but in which method ??
i guess form load method...

You could put it in the form load event handler or in the constructor after the call to InitializeComponent.

This article has been dead for over six months. Start a new discussion instead.