I want in the program that I am creating, when the user clicks on the combo box and selects any of the options, the textbox button label will be created for him, no matter what I try to create the button, it will not be added to the form. Or, for example, if he wants to create this button on another form, and there is another problem with the button, I want it to be disabled for every button that is clicked.
Button button = new Button();
button.show();
>Solution :
you can’t display the button with dot show. With this code, you can create the button and add an event to it.
internal class Create_button
{
public static Button button = new Button();
public static void New(Form what_form,String Text , int Location_X , int Location_Y,Boolean Auto_Size,String Font,int Font_Size)
{
button.Text = Text;
button.Location = new Point(Location_X,Location_Y);
button.AutoSize = Auto_Size;
button.Font = new Font(Font, Font_Size);
what_form.Controls.Add(button);
what_form.CreateControl();
button.Click += new EventHandler(button_Click);
}
private static void button_Click(object sender, EventArgs e) {
button.Enabled = false;
}
}
You can create the button by placing the specification in the class
And in every form you call the class, write this instead of the first field so that the button is created in the same form.
call in Form:
Create_button.New(this, "B", 300, 170, true, "Segoe UI Symbol", 20);