0
我有一個顯示DataGridView的簡單窗體;我想在同一個表單的第一個下面顯示第二個DataGridView對象。1個窗體上的多個DataGridViews
但是當我運行代碼時,它只顯示第一個。當通過調試器運行時,表單列出它有兩個datagridviews鏈接到它。
System.Windows.Forms.Form form
= new System.Windows.Forms.Form();
form.Size = new System.Drawing.Size(450, 400);
form.Text = "Form";
DataGridView dg = new DataGridView();
dg.AllowUserToAddRows = false;
dg.AllowUserToDeleteRows = false;
dg.AllowUserToOrderColumns = true;
dg.Dock = System.Windows.Forms.DockStyle.Fill;
dg.Location = new System.Drawing.Point(0, 0);
dg.ReadOnly = true;
dg.TabIndex = 0;
dg.DataSource = dt;
dg.Parent = form;
DataGridView dgHangers = new DataGridView();
dgHangers.AllowUserToAddRows = false;
dgHangers.AllowUserToDeleteRows = false;
dgHangers.AllowUserToOrderColumns = true;
dgHangers.Dock = System.Windows.Forms.DockStyle.Fill;
// attempting get the bottom of the first DataGridView() so the second will display below.
dgHangers.Location = new System.Drawing.Point(0, dg.DisplayRectangle.Bottom);
dgHangers.ReadOnly = true;
dgHangers.TabIndex = 1;
dgHangers.DataSource = hangerTable;
dgHangers.Parent = form;
form.ShowDialog();
形式:
謝謝! 我知道它必須簡單。 – Ryan
高興。 –