Select cell from column and row index

5 posts, 1 answers
  1. Evil
    Evil avatar
    18 posts
    Member since:
    Mar 2015

    Posted 22 Sep 2015 Link to this post

    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

  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 23 Sep 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Evil
    Evil avatar
    18 posts
    Member since:
    Mar 2015

    Posted 23 Sep 2015 Link to this post

    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





  5. Answer
    Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 25 Sep 2015 Link to this post

    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
  6. Evil
    Evil avatar
    18 posts
    Member since:
    Mar 2015

    Posted 25 Sep 2015 in reply to Yoan Link to this post

    Hello Yoan,

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

    Evelyn

Back to Top
UI for WPF is Visual Studio 2017 Ready