programatically selceting grid.

hi,

I am using griddatabound control.
I have following two queries:

1) How to programatically select a particular cell say cell(10,10) in grid.
2) When I select a cell in the grid using mouse, the cell click event gets fired. How do i get the cell selected event when i navigate through cells using tab key or up/down arrow keys.


2 Replies

HA haneefm Syncfusion Team May 29, 2007 09:56 PM UTC

Hi Dinesh,

1) How to programatically select a particular cell say cell(10,10) in grid?
>>>>>>>>>>>>>>
You can use the Model.Selections property to manages selected ranges in the grid. It allows you to add and remove selections, determines selection state of a specific cell. Here is a code to select (2,2) cell in a grid.

//highlight the cell
this.grid1.Model.Selections.Add(GridRangeInfo.Cell(2,2));
//highlight the row
this.grid1.Model.Selections.Add(GridRangeInfo.Row(RowIndex));
//highlight the cell
this.grid1.Model.Selections.Add(GridRangeInfo.Cell(RowIndex,ColIndex);
//highlight the cell
this.grid1.Model.Selections.Add(GridRangeInfo.Col(CoIIndex));

2) When I select a cell in the grid using mouse, the cell click event gets fired. How do i get the cell selected event when i navigate through cells using tab key or up/down arrow keys.
>>>>>>>>>>>>>>
You can try handle the Model.SelectionChanging event to detect the cell selection in a grid. Please try this and let me know if this helps.

Best regards,
Haneef


DU dinesh upreti May 30, 2007 10:27 AM UTC

hi,

this.grid1.Model.Selections.Add(GridRangeInfo.Cell(2,2));
does makes the cell appear as selected but it doesnot sets the CurrentCell property. I want to programatically set this CurrentCell property.

Thanks

dinesh

>Hi Dinesh,

1) How to programatically select a particular cell say cell(10,10) in grid?
>>>>>>>>>>>>>>
You can use the Model.Selections property to manages selected ranges in the grid. It allows you to add and remove selections, determines selection state of a specific cell. Here is a code to select (2,2) cell in a grid.

//highlight the cell
this.grid1.Model.Selections.Add(GridRangeInfo.Cell(2,2));
//highlight the row
this.grid1.Model.Selections.Add(GridRangeInfo.Row(RowIndex));
//highlight the cell
this.grid1.Model.Selections.Add(GridRangeInfo.Cell(RowIndex,ColIndex);
//highlight the cell
this.grid1.Model.Selections.Add(GridRangeInfo.Col(CoIIndex));

2) When I select a cell in the grid using mouse, the cell click event gets fired. How do i get the cell selected event when i navigate through cells using tab key or up/down arrow keys.
>>>>>>>>>>>>>>
You can try handle the Model.SelectionChanging event to detect the cell selection in a grid. Please try this and let me know if this helps.

Best regards,
Haneef

Loader.
Up arrow icon