Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            var cell     = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
            var value    = cell.Value;
            var newValue = string.Empty;

            if (value != null)
            {
                newValue = value.ToString().Trim();
            }
            if (!this.cellOldValue.Equals(newValue))
            {
                var column = this.dataGridView1.Rows[e.RowIndex].DataBoundItem as Column;
                if (column == null)
                {
                    return;
                }
                string message = string.Empty;
                if (string.IsNullOrEmpty(cellOldValue))
                {
                    message = string.Format("确定要为字段“{0}”添加注释“{1}”吗?", column.Name, newValue);
                }
                else
                {
                    message = string.Format("确定要将字段“{0}”的注释有“{1}”改为“{2}”吗?", column.Name, cellOldValue, newValue);
                }
                if (DialogResult.OK == MessageBoxEx.Confrim(this, message))
                {
                    UpdateComment(column.Name, newValue);
                    if (this.table != null && column.ExtendedProperties != null)
                    {
                        var first = column.ExtendedProperties.FirstOrDefault(o => o.Name.Equals("MS_Description"));
                        first.Value = newValue;
                    }
                    cell.Value = newValue;
                }
                else
                {
                    cell.Value = this.cellOldValue;
                }
            }
        }