本文整理汇总了C#中System.Windows.Forms.DataGridView.CreateControl方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridView.CreateControl方法的具体用法?C# DataGridView.CreateControl怎么用?C# DataGridView.CreateControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridView
的用法示例。
在下文中一共展示了DataGridView.CreateControl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DataSourceBindingContextDependency
public void DataSourceBindingContextDependency ()
{
List<DataItem> dataList = new List<DataItem> ();
dataList.Add (new DataItem ());
dataList.Add (new DataItem ());
DataGridView dgv = new DataGridView ();
dgv.DataSource = dataList;
Assert.IsNull (dgv.BindingContext, "#1");
Assert.IsFalse (dgv.IsHandleCreated, "#2");
Assert.AreEqual (0, dgv.RowCount, "#3");
dgv.DataSource = null;
Form form = new Form ();
form.Controls.Add (dgv);
dgv.DataSource = dataList;
Assert.IsNotNull (dgv.BindingContext, "#4");
Assert.IsFalse (dgv.IsHandleCreated, "#5");
Assert.AreEqual (2, dgv.RowCount, "#6");
dgv.Dispose ();
dgv = new DataGridView ();
dgv.DataSource = dataList;
Assert.IsNull (dgv.BindingContext, "#7");
Assert.IsFalse (dgv.IsHandleCreated, "#8");
Assert.AreEqual (0, dgv.RowCount, "#9");
dgv.CreateControl ();
Assert.IsNull (dgv.BindingContext, "#10");
Assert.IsTrue (dgv.IsHandleCreated, "#11");
Assert.AreEqual (0, dgv.RowCount, "#12");
}
示例2: CurrentCell
public void CurrentCell()
{
DataGridView dgv = new DataGridView ();
dgv.AllowUserToAddRows = false;
Assert.IsNull (dgv.CurrentCell, "A1");
dgv.RowCount = 10;
dgv.ColumnCount = 2;
Assert.AreEqual (10, dgv.RowCount, "B1");
Assert.AreEqual (2, dgv.ColumnCount, "B2");
Assert.IsNull (dgv.CurrentCell, "B3");
dgv.CurrentCell = dgv[1, 9];
Assert.IsNotNull (dgv.CurrentCell, "H1");
Assert.AreEqual (9, dgv.CurrentCell.RowIndex, "H2");
Assert.AreEqual (1, dgv.CurrentCell.ColumnIndex, "H3");
dgv.CurrentCell = null;
Assert.IsNull (dgv.CurrentCell, "C1");
dgv.CurrentCell = dgv[1, 9];
Assert.IsNotNull (dgv.CurrentCell, "D1");
Assert.AreEqual (9, dgv.CurrentCell.RowIndex, "D2");
Assert.AreEqual (1, dgv.CurrentCell.ColumnIndex, "D3");
dgv.RowCount = 9;
Assert.IsNotNull (dgv.CurrentCell, "E1");
Assert.AreEqual (8, dgv.CurrentCell.RowIndex, "E2");
Assert.AreEqual (1, dgv.CurrentCell.ColumnIndex, "E3");
dgv.CurrentCell = dgv[0, 4];
dgv.RowCount = 2;
Assert.IsNotNull (dgv.CurrentCell, "F1");
Assert.AreEqual (1, dgv.CurrentCell.RowIndex, "F2");
Assert.AreEqual (0, dgv.CurrentCell.ColumnIndex, "F3");
dgv.RowCount = 0;
Assert.IsNull (dgv.CurrentCell, "P1");
dgv.RowCount = 10;
Assert.AreEqual (10, dgv.RowCount, "I1");
dgv.CurrentCell = dgv[0, 4];
dgv.ColumnCount = 0;
Assert.AreEqual (0, dgv.RowCount, "I2");
Assert.IsNull (dgv.CurrentCell, "I3");
dgv.RowCount = 0;
dgv.ColumnCount = 0;
dgv.CreateControl ();
dgv.ColumnCount = 2;
dgv.RowCount = 3;
Assert.IsNotNull (dgv.CurrentCell, "G1");
Assert.AreEqual (0, dgv.CurrentCell.RowIndex, "G1");
Assert.AreEqual (0, dgv.CurrentCell.ColumnIndex, "G1");
}