如何在两个面板中显示一个dataGridview

时间:2017-10-23 02:46:11

标签: c# datagridview

我想在两个面板上显示一个DataGridView(一个对象)。

但是,DataGridView仅显示在最后一个面板上(最后一次添加到面板)

如何在两个面板上显示一个DataGridView?

this.dataGridView2.AllowUserToAddRows = false;
this.dataGridView2.AllowUserToDeleteRows = false;
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
        this.matrial_Code,
        this.material_Name,
        this.material_Spec});
this.dataGridView2.Location = new System.Drawing.Point(14, 66);
this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.ReadOnly = true;
this.dataGridView2.RowTemplate.Height = 27;
this.dataGridView2.Size = new System.Drawing.Size(398, 456);
this.dataGridView2.TabIndex = 2;
this.dataGridView2.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellContentClick);
this.dataGridView2.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_DoubleClick);

this.panel1.Controls.Add(this.dataGridView2); //No Display
this.panel2.Controls.Add(this.dataGridView2); //Display

0 个答案:

没有答案