protected override bool Commit(CurrencyManager cm, int row) { // if (!editing) // return true; try { object o = _cb.Text; if (NullText.Equals(o)) { o = System.Convert.DBNull; } SetColumnValueAtRow(cm, row, o); } catch { // EndEdit(); return(false); } // HideComboBox(); // EndEdit(); return(true); }
/// <summary> /// Standard override /// </summary> /// <param name="dataSource"></param> /// <param name="rowNum"></param> /// <returns></returns> protected override bool Commit(CurrencyManager dataSource, int rowNum) { if (!_inEdit) { return(true); } try { object _value = _comboBox.SelectedValue; if (NullText.Equals(_value)) { _value = System.Convert.DBNull; } this.SetColumnValueAtRow(dataSource, rowNum, _value); } catch { return(false); } finally { _inEdit = false; _comboBox.Hide(); } return(true); }
// // Commit Changes // protected override bool Commit(CurrencyManager DataSource, int RowNum) { HideComboBox(); if (!InEdit) { return(true); } try { object Value = Combo.SelectedValue; if (NullText.Equals(Value)) { Value = System.Convert.DBNull; } SetColumnValueAtRow(DataSource, RowNum, Value); } catch { RollBack(); return(false); } this.EndEdit(); return(true); }
/// <summary> /// <para> /// Inititates a request to complete an editing procedure. /// </para> /// </summary> protected internal override bool Commit(CurrencyManager dataSource, int rowNum) { // always hide the edit box // HideEditBox(); edit.Bounds = Rectangle.Empty; if (edit.IsInEditOrNavigateMode) { return(true); } try { object value = edit.Text; if (NullText.Equals(value)) { value = Convert.DBNull; edit.Text = NullText; } else if (format != null && format.Length != 0 && parseMethod != null && FormatInfo != null) { // use reflection to get the Parse method on the // type of the propertyDescriptor. value = (object)parseMethod.Invoke(null, new object[] { edit.Text, FormatInfo }); if (value is IFormattable) { edit.Text = ((IFormattable)value).ToString(format, formatInfo); } else { edit.Text = value.ToString(); } } else if (typeConverter != null && typeConverter.CanConvertFrom(typeof(string))) { value = typeConverter.ConvertFromString(edit.Text); edit.Text = typeConverter.ConvertToString(value); } SetColumnValueAtRow(dataSource, rowNum, value); } catch { // MessageBox.Show("There was an error caught setting field \"" // + this.PropertyDescriptor.Name + "\" to the value \"" + edit.Text + "\"\n" // + "The value is being rolled back to the original.\n" // + "The error was a '" + e.Message + "' " + e.StackTrace // , "Error commiting changes...", MessageBox.IconError); // Debug.WriteLine(e.GetType().Name); RollBack(); return(false); } DebugOut("OnCommit completed without Exception."); EndEdit(); return(true); }
protected override void ConcedeFocus() { if (editing) { object o = _cb.Text; if (NullText.Equals(o)) { o = System.Convert.DBNull; } SetColumnValueAtRow(_CM, _Row, o); } HideComboBox(); EndEdit(); }