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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Highlight row in disabled grid

Thread ID:





65830 Jul 27,2007 01:18 PM UTC Aug 1,2007 08:52 PM UTC WinForms 5
Tags: GridControl
Asked On July 27, 2007 01:18 PM UTC


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 08:33 PM UTC

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 07:33 AM UTC

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 05:29 PM UTC

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 05:31 AM UTC

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 08:52 PM UTC

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon