Home Forums WinForms controls Xceed Grid for WinForms Custom Grid cell – Manually invoke DroppedDown fails

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15262 |

    I’am trying to create a datagrid row that is readonly when the user clicks on the row – but if the user click a key on that row one of the cells in that row should display a combobox and select the first entry that matches the pressed key of the user

    So I’am using a custom row and cell – in the custom row I implement the OnKeyPress-event – first I do is to set “GridControl.AllowCellNavigation = true”, so one specific cell can be selected and switch into edit mode (call to EnterEdit())

    But now is my problem, that when I try to cast the cell to ComboBoxEditor and set the “DroppedDown”-Property I always get the following error

    Cannot drop-down an invisible control or a control that is not on a form.

    If I do not set the property the dropdownbutton is visible and I can click it – but I want to show the dropdowncontrol automatically…

    Is there any chance to solve this problem? Thanks for any help…

    Here my code how I try

    protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
    {
    if (char.IsLetter(e.KeyChar))
    {
    try
    {
    Cell myCell = this.Cells[1];
    this.GridControl.AllowCellNavigation = true;
    myCell.EnterEdit();
    ((Xceed.Grid.Editors.ComboBoxEditor)myCell.CellEditorManager).TemplateControl.DroppedDown = true;
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    //e.Handled = true;
    }
    base.OnKeyPress(e);
    }

    Imported from legacy forums. Posted by Oliver (had 2459 views)

    User (Old forums)
    Member
    Post count: 23064

    The problem is that you are trying to show the dropdown control on the template. You need to do this on the actual instance of the editor.

    So replace this :

    ((Xceed.Grid.Editors.ComboBoxEditor)myCell.CellEditorManager).TemplateControl.DroppedDown = true;

    By this :

    ( ( WinComboBox )myCell.CellEditorControl ).DroppedDown = true;

    Imported from legacy forums. Posted by André (had 225 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks, that works great

    Imported from legacy forums. Posted by Oliver (had 3520 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.