Esempio n. 1
0
        public override object Clone()
        {
            DataGridViewComboBoxButtonColumn column1 = (DataGridViewComboBoxButtonColumn)base.Clone();

            column1.DataSource        = this.DataSource;
            column1.OnCellButtonClick = this.OnCellButtonClick;
            column1.CellTemplate      = new DataGridViewComboBoxButtonCell();
            return(column1);
        }
Esempio n. 2
0
        public override void InitializeEditingControl(int rowIndex, object
                                                      initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            // Set the value of the editing control to the current cell value.
            base.InitializeEditingControl(rowIndex, initialFormattedValue,
                                          dataGridViewCellStyle);

            DataGridViewComboBoxButtonColumn dgcb = this.DataGridView.Columns[this.ColumnIndex] as DataGridViewComboBoxButtonColumn;
            ComboBoxButtonEditingControl     ctl  = DataGridView.EditingControl as ComboBoxButtonEditingControl;

            ctl.InitDataSource(dgcb.DataSource);
            ctl.Init(initialFormattedValue);
            ctl.BackColor   = dataGridViewCellStyle.SelectionBackColor;
            ctl.ColumnIndex = this.ColumnIndex;
        }
Esempio n. 3
0
 protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
 {
     if (value != null)
     {
         DataGridViewComboBoxButtonColumn dgcb = this.DataGridView.Columns[this.ColumnIndex] as DataGridViewComboBoxButtonColumn;
         if (dgcb != null)
         {
             KeyValue item = dgcb.DataSource.Find(q => TryParse.ToString(q.ValueMember) == TryParse.ToString(value));
             if (item != null)
             {
                 this.Value = item.ValueMember;
                 return(item.DisplayMember.ToString());
             }
         }
     }
     return(base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
 }