toop toop - 1 month ago 5
C# Question

c# - difference between Button and System.Windows.Forms.Button?

In my form1 class I have a number of buttons added using the designer. ie button1, button2.etc

In my controller class I've created an array of buttons like:

Btns[k,m] = new Button();

then go:

Btns[1,1].Name = "button1";
Btns[1,1].Visible = False;

But this does not actually change the visibility of the button on my form class. Does anyone know why?

Basically create an array of button names in the controller that actually link to the form buttons in my form1 class.


There is no difference between Button and System.Windows.Forms.Button assuming you are using System.Windows.Forms and there is no ambiguity.

Don't overwrite Btns[k, m] with a new button. That is, remove this line:

Btns[k, m] = new Button();

If Btns is not set from the designer and would have its elements be null, set them to the buttons created from the designer:

Btns[1, 1] = button1;