Пример #1
0
        protected override void Edit(
            System.Windows.Forms.CurrencyManager source,
            int rowNum,
            System.Drawing.Rectangle bounds,
            bool readOnly,
            string instantText,
            bool cellIsVisible)
        {
            DataGridSetDataSourceCellEventArgs e = null;

            if (DataGridSetDataSourceCell != null)
            {
                e = new DataGridSetDataSourceCellEventArgs(rowNum, colNum);
                DataGridSetDataSourceCell(this, e);
            }
            base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
            if (_comboBox != null && DataGridTableStyle.DataGrid.CurrentCell.ColumnNumber == colNum && e.DataSource != null)
            {
                iCurrentRowEdit = rowNum;
                _cmanager       = source;
                DataGridTableStyle.DataGrid.Scroll += new EventHandler(DataGrid_Scroll);
                _comboBox.Parent = TextBox.Parent;
                Rectangle rect = DataGridTableStyle.DataGrid.GetCurrentCellBounds();
                _comboBox.Location      = rect.Location;
                _comboBox.Size          = new Size(TextBox.Size.Width + 4, _comboBox.Size.Height);
                _comboBox.DataSource    = e.DataSource;
                _comboBox.DisplayMember = e.DisplayMember;
                _comboBox.ValueMember   = e.ValueMember;
                if (e.SelectedValue != null)
                {
                    _comboBox.SelectedValue = e.SelectedValue;
                }
                _comboBox.Show();
                _comboBox.BringToFront();
                _comboBox.Focus();
            }
        }
 protected override void Edit(
     System.Windows.Forms.CurrencyManager source,
     int rowNum,
     System.Drawing.Rectangle bounds,
     bool readOnly,
     string instantText,
     bool cellIsVisible)
 {
     DataGridSetDataSourceCellEventArgs e = null;
     if (DataGridSetDataSourceCell != null)
     {
         e = new DataGridSetDataSourceCellEventArgs(rowNum, colNum);
         DataGridSetDataSourceCell(this, e);
     }
     base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
     if(_comboBox != null && DataGridTableStyle.DataGrid.CurrentCell.ColumnNumber == colNum && e.DataSource != null)
     {
         iCurrentRowEdit = rowNum;
         _cmanager = source;
         DataGridTableStyle.DataGrid.Scroll += new EventHandler(DataGrid_Scroll);
         _comboBox.Parent = TextBox.Parent;
         Rectangle rect = DataGridTableStyle.DataGrid.GetCurrentCellBounds();
         _comboBox.Location = rect.Location;
         _comboBox.Size = new Size(TextBox.Size.Width + 4, _comboBox.Size.Height);
         _comboBox.DataSource = e.DataSource;
         _comboBox.DisplayMember = e.DisplayMember ;
         _comboBox.ValueMember = e.ValueMember;
         if(e.SelectedValue != null)
             _comboBox.SelectedValue = e.SelectedValue;
         _comboBox.Show();
         _comboBox.BringToFront();
         _comboBox.Focus();
     }
 }