golocorbin

golocorbin

  • NA
  • 44
  • 101.3k

convert (packing) two dimensional array in one-calculate index member

Mar 11 2008 8:43 AM

Please, answer me,

      I reading  book "Windows Forms Programming in C# " and part :

           void GridForm_Layout(object sender, LayoutEventArgs e) {

                   // Suspend layout until we're finished moving things

                       this.SuspendLayout();

                  // Arrange the buttons in a grid on the form

                  Button[] buttons = new Button[] { button1, ..., };

                  int cx = ClientRectangle.Width/3;

                  int cy = ClientRectangle.Height/3;

                   for( int row = 0; row != 3; ++row ) {

                       for( int col = 0; col != 3; ++col ) {

                          Button button = buttons[col * 3 + row];

                          button.SetBounds(cx * row, cy * col, cx, cy);

               }

            }

               // Set form client size to be multiple of width/height

               SetClientSizeCore(cx * 3, cy * 3);

                // Resume the layout

                  this.ResumeLayout();

           }

               QUESTION

                  the bold fonts part above is :

             1)  private construction of the author

                      or

             2 ) part an mathematicals (linear algebra) rules applying on arrays---

          where I can learn about this rule (calcualte index array members, and packing

         two or three array in one array)

                                     thank you forward


Answers (1)