TableLayoutPanel

    技术2022-06-28  53

    // Create TableLayoutPanelTableLayoutPanel tlp = new TableLayoutPanel(); // Set the BorderStyle to Insettlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset; // Grid has two columnstlp.ColumnCount = 2; // Grid has two rowstlp.RowCount = 2; // If grid is full add extra cells by adding columntlp.GrowStyle = TableLayoutPanelGrowStyle.AddColumns; // Padding (pixels)within each cell (left, top, right, bottom)tlp.Padding = new Padding(1, 1, 4, 5); // Add TableLayoutPanel to the Forms controlsthis.Controls.Add(tlp);/// Create buttonsButton button1 = new Button();button1.Text = "Click Me"; // Resize the TableLayoutPaneltlp.AutoSize = true;// Add buttons to TableLayoutPaneltlp.Controls.Add(button1);

    // Add buttons to TableLayoutPaneltlp.Controls.Add(button1, 1, 0);public virtual void Add(  Control control,  int column,  int row)

    //tableLayoutPanel1.ColumnStyles[0].SizeType = SizeType.Absolute;tableLayoutPanel1.ColumnStyles[0].Width = 20;tableLayoutPanel1.RowStyles[0].SizeType = SizeType.Percent;tableLayoutPanel1.RowStyles[0].Height = 50;/// merge celltlp.SetColumnSpan(button1, 2);//ortlp.SetRowSpan(button1, 2);// from: ---- http://en.csharp-online.net/TableLayoutPanel

     

     

     


    最新回复(0)