Display dropdown arrow when a GridViewMultiComboBoxColumn cell is first activated

4 posts, 1 answers
  1. Ira
    Ira avatar
    4 posts
    Member since:
    Oct 2013

    Posted 18 Dec 2013 Link to this post

    Say you have a GridView whose first column is a GridViewMultiComboBoxColumn.

    When the grid is first activated, the cell belonging to this column in the first row becomes the active cell, but the dropdown arrow button does not display.  You need to click on the cell before the dropdown button is shown. 

    Is there some trick to get the arrow button to display as soon as this cell (or any other cell belonging to the GridViewMultiComboBoxColumn  column) is first activated?

    Thanks.



  2. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 20 Dec 2013 Link to this post

    Hello Ira,

    Thank you for writing. 

    Yes, you can do that by capturing the CurrentCellChanged event and it in, if the new cell column is GridViewMultiComboBoxColumn, then call the cell's BeginEdit method to put it in edit mode:
    void radGridView1_CurrentCellChanged(object sender, CurrentCellChangedEventArgs e)
     {
        if (e.NewCell.ColumnInfo is GridViewMultiComboBoxColumn)
        {
            e.NewCell.BeginEdit();
        }
    }

    I hope this helps. Should you have any other questions or suggestions, do not hesitate to contact us. 

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Ira
    Ira avatar
    4 posts
    Member since:
    Oct 2013

    Posted 20 Dec 2013 Link to this post

    Stefan,

    Thanks very much!

    Playing with this a bit, I found that it would work better for my needs to call BeginEdit at the end of the form Load event.

    My code looks like:

     
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
         ...   ' other stuff
         If (TypeOf RadGridView1.CurrentCell.GridControl.CurrentColumn Is GridViewMultiComboBoxColumn)OrElse _
                (TypeOf RadGridView1.CurrentCell.GridControl.CurrentColumn Is GridViewComboBoxColumn) Then
              RadGridView1.CurrentCell.RowInfo.Cells(RadGridView1.CurrentCell.ColumnIndex).BeginEdit()
         End If
    End Sub


    A couple of questions regarding this:

    1)  Is RadGridView1.CurrentCell.RowInfo.Cells(RadGridView1.CurrentCell.ColumnIndex) the most straightforward way to get the current GridViewCellInfo, for calling BeginEdit on?  Or is there some way that is shorter and/or cleaner?

    2) When the code above executes, the dropdown button does display in the combobox cell that is active at the end of the form load event, but the text insertion cursor is not in this cell.  How can I programmatically get the insertion cursor into this cell? 

    Thanks again.
  4. Answer
    Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 21 Dec 2013 Link to this post

    Hello Ira,

    Thank you for writing back. I am glad you found my answer useful.

    In regards to the questions at hand:
    1. If the cell you want to put in edit mode is not the current one, you do not need to use the CurrentCell and you can work with the following API:
    radGridView1.Rows(0).Cells("YourMultiColumnComboBoxColumnName").BeginEdit()

    2. You can call the BeginEdit method in the Form.Shown event to ensure all the needed layouts have passed, hence you will see the cursor in the editor:
    Protected Overrides Sub OnShown(e As EventArgs)
        MyBase.OnShown(e)
        radGridView1.Rows(0).Cells("MCCB").BeginEdit()
    End Sub

    I hope this helps.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top