This is a migrated thread and some comments may be shown as answers.

Display dropdown arrow when a GridViewMultiComboBoxColumn cell is first activated

3 Answers 107 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ira
Top achievements
Rank 1
Ira asked on 18 Dec 2013, 07:00 AM
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.



3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Dec 2013, 11:20 AM
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 >>
0
Ira
Top achievements
Rank 1
answered on 20 Dec 2013, 07:06 PM
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.
0
Accepted
Stefan
Telerik team
answered on 21 Dec 2013, 11:15 AM
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 >>
Tags
GridView
Asked by
Ira
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Ira
Top achievements
Rank 1
Share this question
or