请问在WINFORM里面怎么放Table

解决方案 »

  1.   

    你需要什么功能?datagridview?
      

  2.   

    WinForm中的DataGridView类似于WebForm中的GridView
      

  3.   

    WinForm里和Table类型的有DataGridView,DataGrid,ListView,ListBox等。
      

  4.   


           lz需要 布局的话,  panel  是最好用的 
       
           
      

  5.   

    TableLayOutPanel 可以实现Table功能。主要是在有用的cell里面new一个textbox或者label
      

  6.   

    可否给个TableLayOutPanel 例子
      

  7.   

                //显示边界
                tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;            //考虑到tableLayoutPanel1.GrowStyle,每次刷新前清除control
                tableLayoutPanel1.Controls.Clear();            //显示行=5,列=5
                tableLayoutPanel1.RowCount = 5;
                tableLayoutPanel1.ColumnCount = 5;
                #region 行和列大小一致
                TableLayoutColumnStyleCollection cols = tableLayoutPanel1.ColumnStyles;
                for (int i = 0; i < cols.Count; i++)
                {
                    cols[i].SizeType = SizeType.Percent;
                    cols[i].Width = 100 / cols.Count;
                }
                TableLayoutRowStyleCollection rows = tableLayoutPanel1.RowStyles;
                for (int i = 0; i < rows.Count; i++)
                {
                    rows[i].SizeType = SizeType.Percent;
                    rows[i].Height = 100 / rows.Count;
                }            #endregion            
                //为每个Cell添加一个控件。(简单起见,添加label)
                for (int i = 0; i < tableLayoutPanel1.ColumnCount; i++)
                {
                    for (int j = 0; j < tableLayoutPanel1.RowCount; j++)
                    {
                        Label label = new Label();
                        label.Text = "Col:" + i.ToString() + ";Row:" + j.ToString();
                        tableLayoutPanel1.Controls.Add(label, i, j);
                    }
                }            //设置大小
                tableLayoutPanel1.Size = new Size(600, 400);
                tableLayoutPanel1.Update();