當前位置: 首頁>>代碼示例>>C#>>正文


C# DataGridView.CommitEdit方法代碼示例

本文整理匯總了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;
        }
開發者ID:haoxinqing,項目名稱:DataVerification,代碼行數:58,代碼來源:DataCheck.cs

示例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();
            //    }
            //}
        }
開發者ID:gregggdavis,項目名稱:exersuiteww,代碼行數:18,代碼來源:CQuiz.cs

示例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();
 }
開發者ID:mrandt,項目名稱:LitePlacer-DEV,代碼行數:13,代碼來源:MainForm.cs


注:本文中的System.Windows.Forms.DataGridView.CommitEdit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。