This is a migrated thread and some comments may be shown as answers.

Select cell from column and row index

4 Answers 852 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Evelyn
Top achievements
Rank 1
Evelyn asked on 22 Sep 2015, 07:09 PM

I would like to select a specific cell by giving the column and the row index. For exemple (Image): 

I would like to select the cell where the column index is 2 and the row index is 2 (It will select the cell where "Portugal" is written).

It should be something like myGrid.SelectCell(Columns[2], Rows[2]);

Is there any way of doing this?

Thank you,
Evelyn

4 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 23 Sep 2015, 06:28 AM
Hello Evelyn,

I would suggest you to check the Programmatic Selection help article for a reference.

Regards,
Yoan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Evelyn
Top achievements
Rank 1
answered on 23 Sep 2015, 03:09 PM
I checked the article but I couldn't understand something:

GridViewCellInfo cellToSelect = new GridViewCellInfo(item, column, this.radGridView);
This constructors expect 3 parameters: an object, GridViewColumn, GridViewDataControl.

To get the second parameter (GridViewColumn), I code like this: Telerik.Windows.Controls.GridViewColumn column = this.Columns[0];. It gets the first column of my grid. And the third paremeter, I reference the radgrid itself. But I can't understand what is this object paramenter that is required.. Can you explain to me?

Thank you,
Evelyn





0
Accepted
Yoan
Telerik team
answered on 25 Sep 2015, 12:11 PM
Hi Evelyn,

This is the business object behind (the item) behind the row. You want to select a cell using a code similar to the following one:
SelectCell(Columns[2], Rows[2]);
using the GridViewCellInfo you can use very similar code to "find" the needed cell. You can use directly GridView's Items collection like so:
cellToSelect = new GridViewCellInfo(this.clubsGrid.Items[0], this.clubsGrid.Columns[1], this.clubsGrid);
 
Then you need to add this cell in GridView's SelectedCells collection.

Regards,
Yoan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Evelyn
Top achievements
Rank 1
answered on 25 Sep 2015, 01:16 PM

Hello Yoan,

Thank you so much for your attention. It worked just fine.

Evelyn

Tags
GridView
Asked by
Evelyn
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Evelyn
Top achievements
Rank 1
Share this question
or