First we have to create an Instance for a button:
Button myButton = new Button();
Give some name for the button:
myButton.Name = "ButtonX";
Give the location to the button, basically it is necessary because we need to position it on the form at some given X,Y coordinates; if this value is not given the default position take would be (0,0), that is the starting position of the form:
myButton.Location = new Point(80,80);
Text value of the button is given like this:
myButton.Text = "Click me";
Finally and the most important of all, we are required to add this control to the forms controls, else this control would not be used by the code or program:
this.Controls.Add(myButton);
Completed……Enjoy!!!
No comments:
Post a Comment