本文整理汇总了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();
}