Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Get Cell Value of selected Column in Row in UIGridView
posted

Hey - Pretty simple question, but not sure what is the quickest way to do this. I'm just looking to get the value of a column in the selected row of the UIGridView in C# Monotouch.

 

Any sample snippets would be great, I'm currently using the IGGridViewDataSourceHelper to easily populate data in the GridView. I have a selected row containing 3 columns I want to get the selected value of column 1 in the GridView.

 

 

Parents
No Data
Reply
  • 40030
    Verified Answer
    Offline posted

    Hi!

    Sure, thats no problem. To retrieve the selected row, you'll use the SelectedRowPath() method on the IGGridView, and then use the ResolveDataValueForCell() method on the IGGridViewDataSourceHelper. 

    So it will look like this: 

    IGRowPath row = _gridView.SelectedRowPath ();
    NSObject obj = _dsh.ResolveDataValueForCell (new IGCellPath(row.RowIndex, row.SectionIndex, 0));

    Basically, we're asking for the path of the selected row. 

    Then we're taking that path, and asking the DataSourceHelper to look up a specific value by creating a cell path. Note the when we create the IGCellPath, we're passing in zero as the last parameter. That's b/c we want the first column.

    Hope this helps, 

    -SteveZ

Children
No Data