本文整理汇总了C#中System.Windows.Forms.DataGridView.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridView.Dispose方法的具体用法?C# DataGridView.Dispose怎么用?C# DataGridView.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DataGridView
的用法示例。
在下文中一共展示了DataGridView.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditingControlShowingTest_Unbound
[Test] // Xamarin bug 5419
public void EditingControlShowingTest_Unbound ()
{
using (DataGridView _dataGridView = new DataGridView ()) {
DataGridViewComboBoxColumn _nameComboBoxColumn;
DataGridViewTextBoxColumn _firstNameTextBoxColumn;
DataGridViewCheckBoxColumn _chosenCheckBoxColumn;
// Add the event-handler.
_dataGridView.EditingControlShowing
+= new DataGridViewEditingControlShowingEventHandler
(DataGridView_EditingControlShowingTest);
// No columns have been found in the event-handler yet.
editingControlShowingTest_FoundColumns = 0;
// _nameComboBoxColumn
_nameComboBoxColumn = new DataGridViewComboBoxColumn ();
_nameComboBoxColumn.HeaderText = "Name";
_dataGridView.Columns.Add (_nameComboBoxColumn);
// _firstNameTextBoxColumn
_firstNameTextBoxColumn = new DataGridViewTextBoxColumn ();
_firstNameTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
_firstNameTextBoxColumn.HeaderText = "First Name";
_dataGridView.Columns.Add (_firstNameTextBoxColumn);
// _chosenCheckBoxColumn
_chosenCheckBoxColumn = new DataGridViewCheckBoxColumn ();
_chosenCheckBoxColumn.HeaderText = "Chosen";
_dataGridView.Columns.Add (_chosenCheckBoxColumn);
// .NET requires that all possible values for combo-boxes in a column
// are added to the column.
_nameComboBoxColumn.Items.Add ("de Icaza");
_nameComboBoxColumn.Items.Add ("Toshok");
_nameComboBoxColumn.Items.Add ("Harper");
_nameComboBoxColumn.Items.Add ("Boswell");
// Set up the contents of the data-grid.
_dataGridView.Rows.Add ("de Icaza", "Miguel", true);
_dataGridView.Rows.Add ("Toshok", "Chris", false);
_dataGridView.Rows.Add ("Harper", "Jackson", false);
_dataGridView.Rows.Add ("Boswell", "Steven", true);
// Edit a combo-box cell.
_dataGridView.CurrentCell = _dataGridView.Rows[3].Cells[0];
Assert.AreEqual (true, _dataGridView.Rows[3].Cells[0].Selected, "1-6");
Assert.AreEqual (true, _dataGridView.BeginEdit (false), "1-7");
_dataGridView.CancelEdit();
// Edit a text-box cell.
_dataGridView.CurrentCell = _dataGridView.Rows[0].Cells[1];
Assert.AreEqual (false, _dataGridView.Rows[3].Cells[0].Selected, "1-8");
Assert.AreEqual (true, _dataGridView.Rows[0].Cells[1].Selected, "1-9");
Assert.AreEqual (true, _dataGridView.BeginEdit (false), "1-10");
_dataGridView.CancelEdit();
// Edit a check-box cell.
_dataGridView.CurrentCell = _dataGridView.Rows[3].Cells[2];
Assert.AreEqual (false, _dataGridView.Rows[0].Cells[1].Selected, "1-11");
Assert.AreEqual (true, _dataGridView.Rows[3].Cells[2].Selected, "1-12");
Assert.AreEqual (true, _dataGridView.BeginEdit (false), "1-13");
_dataGridView.CancelEdit();
// Make sure the event-handler was called each time.
// (DataGridViewCheckBoxCell isn't derived from Control, so the
// EditingControlShowing event doesn't get called for it.)
Assert.AreEqual (3, editingControlShowingTest_FoundColumns, "1-14");
_dataGridView.Dispose();
}
}
示例2: TestDispose
[Test] // Novell bug 660986
public void TestDispose ()
{
DataGridView dgv = new DataGridView ();
dgv.Columns.Add ("TestColumn", "Test column");
dgv.Rows.Add ();
dgv.Dispose ();
Assert.Throws (typeof (ArgumentOutOfRangeException), delegate { DataGridViewColumn col = dgv.Columns[0]; }, "#1");
Assert.Throws (typeof (ArgumentOutOfRangeException), delegate { DataGridViewRow row = dgv.Rows[0]; }, "#2");
}
示例3: Show
/// <summary>
/// Show editor for config management
/// </summary>
public void Show()
{
configForm = new Form();
buttonClose = new Button();
buttonCancel = new Button();
dgView = new DataGridView();
dgView.Parent = configForm;
dgView.BringToFront();
dgView.RowHeadersVisible = false;
buttonCancel.Parent = configForm;
buttonClose.Parent = configForm;
configForm.Text = "Config Editor";
configForm.FormBorderStyle = FormBorderStyle.FixedDialog;
configForm.MaximizeBox = false;
configForm.MinimizeBox = false;
configForm.StartPosition = FormStartPosition.CenterParent;
Parameterlist.Clear();
SetSize();
dgView.Rows.Clear();
try
{
Parameterlist = Read();
}
catch
{
MessageBox.Show("File Not Found, creating SQL default");
InitSQLDefaults();
Parameterlist = Read();
}
dgView.Columns.Add("dgName", "Name");
dgView.Columns.Add("dgValue", "Value");
dgView.Columns["dgName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dgView.Columns["dgName"].FillWeight = 40;
dgView.Columns["dgValue"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dgView.Columns["dgValue"].FillWeight = 60;
foreach (CParameter x in Parameterlist)
{
dgView.Rows.Add();
dgView.Rows[dgView.Rows.Count - 2].Cells[0].Value = x.Name;
dgView.Rows[dgView.Rows.Count - 2].Cells[1].Value = x.Value;
}
buttonClose.Click += new EventHandler(buttonClose_Click);
buttonCancel.Click += new EventHandler(buttonCancel_Click);
dgView.KeyDown += new KeyEventHandler(dgView_KeyDown);
configForm.ShowDialog();
configForm.Dispose();
buttonClose.Dispose();
buttonCancel.Dispose();
dgView.Dispose();
GC.Collect();
}
示例4: 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");
}
示例5: TestDispose
[Test] // Novell bug 660986
public void TestDispose ()
{
DataGridView dgv = new DataGridView ();
dgv.Columns.Add ("TestColumn", "Test column");
dgv.Rows.Add ();
dgv.Dispose ();
try {
DataGridViewColumn col = dgv.Columns[0];
Assert.Fail ("#1");
}
catch (ArgumentOutOfRangeException) {
}
try {
DataGridViewRow row = dgv.Rows[0];
Assert.Fail ("#2");
}
catch (ArgumentOutOfRangeException) {
}
}