Articles in this section

How to focus on next cell when the ComboBox dropdown is closed in WinForms GridControl?

Change the focus to the next cell


In WinForms GridControl, on closing the ComboBox dropdown, focus is maintained in the same cell. You can change the focus to the next cell while closing the dropdown in the GridControl by using the CurrentCell.MoveTo method and set the focus by using the GridSetCurrentCellOptions property.

The following code examples explain how to focus on the next cell in the CurrentCellCloseDropDown event.

// setting ComboBox for first column.
GridStyleInfo style = this.gridControl1.ColStyles[1] as GridStyleInfo;
style.CellType = "ComboBox";
style.ChoiceList = items;
style.DropDownStyle = GridDropDownStyle.Exclusive;
style.ShowButtons = GridShowButtons.Show;

//hooking CurrentCellCloseDropDown event.
this.gridControl1.CurrentCellCloseDropDown += new PopupClosedEventHandler(gridControl1_CurrentCellCloseDropDown);

void gridControl1_CurrentCellCloseDropDown(object sender, PopupClosedEventArgs e)
{
    GridCurrentCell cc = this.gridControl1.CurrentCell;
    // setting focus to the next cell.
    this.gridControl1.CurrentCell.MoveTo(cc.RowIndex, cc.ColIndex + 1, GridSetCurrentCellOptions.SetFocus);
}
'setting ComboBox for first column.
Private style As GridStyleInfo = TryCast(Me.gridControl1.ColStyles(1), GridStyleInfo)
style.CellType = "ComboBox"
style.ChoiceList = items
style.DropDownStyle = GridDropDownStyle.Exclusive
style.ShowButtons = GridShowButtons.Show

'hooking CurrentCellCloseDropDown event.
AddHandler Me.gridControl1.CurrentCellCloseDropDown, AddressOf gridControl1_CurrentCellCloseDropDown

Private Sub gridControl1_CurrentCellCloseDropDown(ByVal sender As Object, ByVal e As PopupClosedEventArgs)
   Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell
   'setting focus to the next cell
   Me.gridControl1.CurrentCell.MoveTo(cc.RowIndex,cc.ColIndex+1, GridSetCurrentCellOptions.SetFocus)
End Sub

In the image below, after choosing a value for the first cell, the current cell is moved to the next one.


Show the current cell moved to next cell


Samples:

C#: Move_nextcell_C#

VBMove_nextcell_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied