Articles in this section
Category / Section

How to make GridControl behave like ListBox, selecting whole rows and not showing a currentcell?

4 mins read

Description

Need to make WinForms GridControl work like ListBox.

Solution

You need to do two things to make the GridControl work like ListBox. To achieve this requirement, you need to change the ListBoxSelectionMode and explicitly set the column index to 0 by using currentCellMoving and CurrentCellActivating events.

The following code examples are for changing ListBoxSelectionMode.

C#

// Changing the GridControlSelectionMode
this.gridControl1.ListBoxSelectionMode = SelectionMode.One;

VB

' Changing the GridControlSelectionMode
Me.gridControl1.ListBoxSelectionMode = SelectionMode.One

The following code example is for setting column index to 0.

C#

private void gridControl1_CurrentCellMoving(object sender, GridCurrentCellMovingEventArgs e)
{
  e.ColIndex = 0;
}
private void gridControl1_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e)
{
   e.ColIndex = 0;
}

VB

Private Sub gridControl1_CurrentCellMoving(ByVal sender As Object, ByVal e As GridCurrentCellMovingEventArgs)
   e.ColIndex = 0
End Sub
Private Sub gridControl1_CurrentCellActivating(ByVal sender As Object, ByVal e As GridCurrentCellActivatingEventArgs)
   e.ColIndex = 0
End Sub

The following screenshot is for GridControl without CurrentCell selection.

Selecting the row on clicking a cell without showing current cell in WinForms GridControl

Figure 1: Selecting the row on clicking a cell without showing current cell

Sample:

C#: GridControl like ListBox CS

VB: GridControl like ListBox VB

Conclusion

I hope you enjoyed learning about how to make GridControl behave like ListBox, selecting whole rows and not showing a currentcell.

You can refer to our  WinForms GridControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our   WinForms GridControl documentation to understand how to present and manipulate data.

For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms GridControl and other WinForms components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

 

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