本文整理匯總了C#中System.Windows.Forms.DataGridView.CommitEdit方法的典型用法代碼示例。如果您正苦於以下問題:C# DataGridView.CommitEdit方法的具體用法?C# DataGridView.CommitEdit怎麽用?C# DataGridView.CommitEdit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.DataGridView
的用法示例。
在下文中一共展示了DataGridView.CommitEdit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RowIdentical
/// <summary>
/// 行一致離開
/// </summary>
/// <param name="dataGridView"></param>
/// <returns></returns>
private static bool RowIdentical(DataGridView dataGridView)
{
//add by dwq 2015-05-27 先提交最後一次輸入DataGridView的數據
if (dataGridView.IsCurrentCellDirty)
{
dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
List<object> objListNull = new List<object>();
List<object> objListNotNull = new List<object>();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (!row.IsNewRow)
{
for (int i = 0; i < row.Cells.Count; i++)
{
if (row.Cells[i].Value == null || row.Cells[i].Value.ToString().Trim() == string.Empty)
{
objListNull.Add(row.Cells[i].Value);
}
else
{
objListNotNull.Add(row.Cells[i].Value);
}
}
}
if (objListNull.Count != 0 && objListNotNull.Count != 0)
{
TipForm tip = new TipForm(dataGridView, "請完整填寫當前表格整行數據");
tip.Show();
if (!dataGridView.Parent.Focused)
{
dataGridView.Parent.Focus();
}
dataGridView.Focus();
//Form frm = UtilClass.SearchOwner(dataGridView) as Form;
//frm.Activate();
foreach (DataGridViewCell item in row.Cells)
{
if (item.Value == null)
{
dataGridView.Focus();
dataGridView.CurrentCell = item;
}
}
return false;
}
}
return true;
}
示例2: AcceptChanges
public void AcceptChanges(DataGridView dataGridCurrent)
{
if (dataGridCurrent.IsCurrentCellDirty || dataGridCurrent.IsCurrentRowDirty)
{
dataGridCurrent.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
dataGridCurrent.EndEdit();
//dataGridCurrent.is
//DataTable table = dataGridCurrent.DataSource as DataTable;
//if (table.GetChanges() != null)
//{
// foreach (DataRow row in table.Rows)
// {
// row.AcceptChanges();
// }
//}
}
示例3: Update_GridView
// =================================================================================
// Forcing a DataGridview display update
// Ugly hack if you ask me, but MS didn't give us any other reliable way...
private void Update_GridView(DataGridView Grid)
{
Grid.CommitEdit(DataGridViewDataErrorContexts.Commit);
BindingSource bs = new BindingSource(); // create a BindingSource
bs.DataSource = Grid.DataSource; // copy jobdata to bs
DataTable dat = (DataTable)(bs.DataSource); // make a datatable from bs
Grid.DataSource = dat; // and copy datatable data to jobdata, forcing redraw
Grid.RefreshEdit();
Grid.Refresh();
}