本文整理汇总了C#中System.Windows.Forms.DataGridViewRow.SetIndex方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewRow.SetIndex方法的具体用法?C# DataGridViewRow.SetIndex怎么用?C# DataGridViewRow.SetIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridViewRow
的用法示例。
在下文中一共展示了DataGridViewRow.SetIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
// FIXME: Do *not* allow insertation *after* the editing row!
public virtual void Insert (int rowIndex, DataGridViewRow dataGridViewRow)
{
dataGridViewRow.SetIndex (rowIndex);
dataGridViewRow.SetDataGridView (dataGridView);
CompleteRowCells (dataGridViewRow);
list.Insert (rowIndex, dataGridViewRow);
ReIndex ();
OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, dataGridViewRow));
if (raiseEvent)
DataGridView.OnRowsAddedInternal (new DataGridViewRowsAddedEventArgs (rowIndex, 1));
}
示例2: AddCore
private int AddCore (DataGridViewRow dataGridViewRow, bool sharable)
{
if (dataGridView.Columns.Count == 0)
throw new InvalidOperationException ("DataGridView has no columns.");
int result;
dataGridViewRow.SetDataGridView (dataGridView);
//
// Add the row just before the editing row (if there is an editing row).
//
int editing_index = -1;
if (DataGridView != null && DataGridView.EditingRow != null && DataGridView.EditingRow != dataGridViewRow) {
editing_index = list.Count - 1; // always the last row
DataGridView.EditingRow.SetIndex (list.Count);
}
if (editing_index >= 0) {
list.Insert (editing_index, dataGridViewRow);
result = editing_index;
} else {
result = list.Add (dataGridViewRow);
}
if (sharable && CanBeShared (dataGridViewRow)) {
dataGridViewRow.SetIndex (-1);
} else {
dataGridViewRow.SetIndex (result);
}
CompleteRowCells (dataGridViewRow);
for (int i = 0; i < dataGridViewRow.Cells.Count; i++) {
dataGridViewRow.Cells [i].SetOwningColumn (dataGridView.Columns [i]);
}
if (raiseEvent) {
OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, dataGridViewRow));
DataGridView.OnRowsAddedInternal (new DataGridViewRowsAddedEventArgs (result, 1));
}
return result;
}