110,536
社区成员
发帖
与我相关
我的任务
分享
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn c in this.dataGridView2.Columns)
{
dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = 1;
dgvr.Cells[1].Value = "张三";
dgvr.Cells[2].Value = "深圳";
dgvr.Cells[3].Value = "张三";
dgvr.Cells[4].Value = "深圳";
this.dataGridView2.Rows.Add(dgvr);
“System.InvalidOperationException”类型的第一次机会异常在 System.Windows.Forms.dll 中发生
在 System.Windows.Forms.Control.get_Handle()
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.DataGridView.LayoutScrollBars()
在 System.Windows.Forms.DataGridView.ComputeLayout()
在 System.Windows.Forms.DataGridView.PerformLayoutPrivate(Boolean useRowShortcut, Boolean computeVisibleRows, Boolean invalidInAdjustFillingColumns, Boolean repositionEditingControl)
在 System.Windows.Forms.DataGridView.ResetUIState(Boolean useRowShortcut, Boolean computeVisibleRows)
在 System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged_PreNotification(CollectionChangeAction cca, Int32 rowIndex, Int32 rowCount, DataGridViewRow& dataGridViewRow, Boolean changeIsInsertion)
在 System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged(CollectionChangeEventArgs e, Int32 rowIndex, Int32 rowCount, Boolean changeIsDeletion, Boolean changeIsInsertion, Boolean recreateNewRow, Point newCur线程 '<无名称>' (0x219c) 已退出,返回值为 0 (0x0)。
rentCell)
在 System.Windows.Forms.DataGridViewRowCollection.InsertInternal(Int32 rowIndex, DataGridViewRow dataGridViewRow, Boolean force)
在 System.Windows.Forms.DataGridViewRowCollection.InsertInternal(Int32 rowIndex, DataGridViewRow dataGridViewRow)
在 System.Windows.Forms.DataGridViewRowCollection.AddInternal(DataGridViewRow dataGridViewRow)
在 System.Windows.Forms.Da
taGridViewRowCollection.Add(DataGridViewRow dataGridViewRow)this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dataGridViewTextBoxColumn1,
this.dataGridViewTextBoxColumn2,
this.dataGridViewTextBoxColumn3,
this.dataGridViewTextBoxColumn5,
this.dataGridViewTextBoxColumn6});
this.dataGridView2.Location = new System.Drawing.Point(8, 54);
this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.RowTemplate.Height = 23;
this.dataGridView2.Size = new System.Drawing.Size(516, 424);
this.dataGridView2.StandardTab = true;
this.dataGridView2.TabIndex = 24;
this.dataGridView2.ColumnCount = 5;
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn c in this.dataGridView2.Columns)
{
dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = 1;
dgvr.Cells[1].Value = "张三";
dgvr.Cells[2].Value = "深圳";
dgvr.Cells[3].Value = "张三";
dgvr.Cells[4].Value = "深圳";
this.dataGridView2.Rows.Add(dgvr);
this.dataGridView2.Refresh();