Using system; Using system. drawing; Using system. collections; Using system. componentmodel; Using system. Windows. forms; Using system. Data; Namespace miner { /// /// Summary des cription for form1. /// Public class form1: system. Windows. Forms. Form { Private system. Windows. Forms. Panel Panel1; /// /// Required designer variable. /// /// Private button [] n = new button [100]; Private int [] kN = new int [100]; Private system. componentmodel. Container components = NULL; Public form1 () { // // Required for Windows Form Designer support // Initializecomponent (); // // Todo: add Any constructor code after initializecomponent call // } /// /// Clean up any resources being used. /// Protected override void dispose (bool disposing) { If (disposing) { If (components! = NULL) { Components. Dispose (); } } Base. Dispose (disposing ); } # region windows Form Designer generated code // required method for designer support-do not modify // The contents this method with the code editor. // private void initializecomponent () {< br> This. panel1 = new system. windows. forms. panel (); This. suspendlayout (); // Panel1 // This. panel1.location = new system. drawing. point (8, 8); This. panel1.name = "Panel1"; This. panel1.size = new system. drawing. size (400,400); This. panel1.tabindex = 0; // form1 // This. autoscalebasesize = new system. drawing. size (6, 14); This. backcolor = system. drawing. color. white; This. clientsize = new system. drawing. size (416,413); This. controls. addrange (new system. windows. forms. control [] { This. panel1}); This. name = "form1"; This. TEXT = "form1"; This. load + = new system. eventhandler (this. form1_load); This. resumelayout (false); } # Endregion /// /// The main entry point for the application. /// [Stathread] Static void main () { Application. Run (New form1 ()); } Private void form1_load (Object sender, system. eventargs E) { Int A = 0; Int x = 0, y = 0; For (A = 0; A <= 99; A ++) { N [a] = new button (); N [A]. backcolor = color. White; N [A]. flatstyle = flatstyle. Flat; N [A]. width = panel1.width/10; N [A]. Left = x * n [A]. width; N [A]. Height = panel1.height/10; N [A]. Top = y * n [A]. height; N [A]. Name = "B" +; Panel1.controls. Add (N [a]); Panel1.controls [A]. mousedown + = new mouseeventhandler (this. buttonarray_onclick );
X + = 1; If (x = 10) { X = 0; Y + = 1; } } } private void buttonarray_onclick (Object sender, mouseeventargs e) {< br> mouseeventargs Arg = (mouseeventargs) E; button b1 = (button) sender; If (Arg. button = mousebuttons. right) b1.backcolor = color. white; else {< br> // b1.backcolor = color. white; b1.image = image. fromfile ("f :\\ My Documents \ my pictures \ elements \ regular_smile.gif "); }< br> }< BR >} |