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. Image for the cookie policy date

Remaining selection on a cell after refresh

Hi!
I update contents of GridControl on timer, but the cell previously selected must remain selected after refresh (i.e. with selection border). I can save its row and col before updating, but how can I programmatically select it again? And show selection BORDER!

Thank you.

4 Replies

HA haneefm Syncfusion Team March 28, 2007 08:36 PM UTC

Hi Andrey,

One way you can do this by using the Model.Selections property. The Model.Selections property allows you to add, remove and get selections, determines selection state of a specific cell. Here is a code

//Before calling the Refresh method you need to store the selected range to the GridRangeInfoList
GridRangeInfoList list;
this.gridControl1.Model.Selections.GetSelectedRanges(out list,true);
this.gridControl1.Refresh();

//and then set the list as selected range in a grid after calling the refresh.
foreach(GridRangeInfo info in list)
this.gridControl1.Model.Selections.Add(info);

Best regards,
Haneef


AG Andrey Gruber March 29, 2007 09:31 AM UTC

Hi, Haneef!
The code above works fine except the fact I need to see a border around the cell, as after mouse click - in the color scheme we work with, the selection color is light gray and is almost not visible. In other words, I need to emulate mouse click on the cell in order to see selection border.


HA haneefm Syncfusion Team March 29, 2007 07:41 PM UTC

Hi Andrey,

Please try this code.

int RowIndex = this.grid.CurrentCell.RowIndex;
int ColIndex = this.grid.CurrentCell.ColIndex;

this.grid.Refresh();

this.grid.CurrentCell.MoveTo( RowIndex,ColIndex ,GridSetCurrentCellOptions.SetFocus);


Best regards,
Haneef


AG Andrey Gruber March 30, 2007 07:09 AM UTC

Thank you - it works!

Loader.
Live Chat Icon For mobile
Up arrow icon