private void InitTabPage() { mainTabControl.TabPages.Clear(); mainTabControl.TabPages.Add("0", "Main"); mainTabControl.TabPages[0].AutoScroll = true; for (int i = 0; i < ConfigLayer.unitCount; i++) { /*** Вкладки ********************************** ***********************************************/ mainTabControl.TabPages.Add((i + 1).ToString(), " " + (i + 1).ToString()); _itemsGraph[i] = new ItemGraph(i); _itemsGraph[i].Dock = DockStyle.Fill; mainTabControl.TabPages[i + 1].Controls.Add(_itemsGraph[i]); /*** Квадраты на главной *********************** ************************************************/ _itemsControl[i] = new ItemControl(i); _itemsControl[i].Tag = i; _itemsControl[i].ItemClick += ItemsControl_Click; //по 5 в ряд и 1 отступ int x = (i % 5) * (_itemsControl[i].Size.Width + 1); int y = (i / 5) * (_itemsControl[i].Size.Height + 1); _itemsControl[i].Location = new Point(x, y); mainTabControl.TabPages[0].Controls.Add(_itemsControl[i]); } }