We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Highlight row in disabled grid

Thread ID:





65830 Jul 27,2007 09:18 AM Aug 1,2007 04:52 PM Windows Forms 5
Tags: GridControl
Asked On July 27, 2007 09:18 AM


I'm using your GridControl to show a simple list of objects and I want to highlight the selected row. But I don't want the user to edit in this grid, so I set the Enabled = false for all the cells. If I only set ReadOnly = true, the user can still click in a cell and mark text. I don't want this behaviour.

How is the best way to highlight the selected row in this case.

Thanks in advance,

Rajagopal [Syncfusion]
Replied On July 27, 2007 04:33 PM

Hi Kjetil,

To make the whole row selected by clicking on any of the cells, add the code below. This will work fine even for disabled cells.

this.gridControl1.ListBoxSelectionMode = SelectionMode.One;

Let us know if you have any other questions.

Replied On July 30, 2007 03:33 AM

Hi and thanks for a prompt reply!

This information helps. So by setting Enabled = false for the whole table, and setting the SelectionMode to One, the grid looks and behaves the way I want.

But since all cells are disabled, I can't use .CurrentCell. What is the best way to find the row that is selected. It looks like I can find the information under GridControl.Model.SelectedRanges. Is that what I should use?

Rajagopal [Syncfusion]
Replied On July 30, 2007 01:29 PM

Hi Kjetil,

You could determine the clicked row using the grid.PointToRowCol() method in the MouseDown event of the grid.

int row, col;
void gridControl1_MouseDown(object sender, MouseEventArgs e)
Point pt = new Point(e.X, e.Y);
this.gridControl1.PointToRowCol(pt, out row, out col);
Console.WriteLine("RowIndex: {0}", row);


Replied On August 1, 2007 01:31 AM

Hi Rajogopal,

Well I use the CellClick event, and there I can use the e.RowIndex to find the row clicked. This works even if all the cells are disabled. The problem however is when the user clicks a button outside the grid to edit the selected record. Then I want to find the selected row.

haneefm [Syncfusion]
Replied On August 1, 2007 04:52 PM

Hi Kjetil,

In both GridControl and GridDataBoundGrid classes, there is a member Selections which you can use to access exactly what cells are selected in the grid. This Selections class has a GetSelectedRows method that returns an array of ranges that are selected row ranges. You can iterate through this array to get all the ranges. So, to get the row index of this selected row , you can use code such as:

GridRangeInfoList list = this.gridDataBoundGrid1.Model.Selections.GetSelectedRows(true, true);
foreach (GridRangeInfo range in list)
Console.WriteLine("RowIndex : " + range.Top);

Best regards,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.