Home Forums WinForms controls Xceed Grid for WinForms Accessing the Underlining Object in a DataRow

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #12688 |

    Hey there!

    I have a (many actually) grid who’s datasource is set to an arraylist. This arraylist has an array of objects in it. Display and editing of this structure is seamless and works very well. However, I have come to a point where I need to iterate through the rows in the grid looking at each row and having access to the object in which the data is located.

    Is it as simple as
    foreach (Xceed.grid.row myrow in gridControl1.DataRows)
    {
    myobject temp = myrow.Tag; 😛
    // more code
    }

    Yeah didn’t think so. Please fill me in! Quick. =:O

    Thanks
    Nick

    Imported from legacy forums. Posted by Buggi (had 5221 views)

    User (Old forums)
    Member
    Post count: 23064

    Hmmm.. I just thought of something, if the data is bound to the array list, than I just need to parse through the array list.

    DOH!!!

    Imported from legacy forums. Posted by Buggi (had 409 views)

    Xceed Support
    Member
    Post count: 5658

    Hello,

    The Index of the DataRow will represent the index in your ArrayList. Therefore, if your DataRow has an index of 1, it will correspond to the second (arrayList[ 1 ]) item in your ArrayList.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 460 views)

    User (Old forums)
    Member
    Post count: 23064

    Not if they’ve resorted the grid via a columnheader. 🙂

    Imported from legacy forums. Posted by Buggi (had 345 views)

    Xceed Support
    Member
    Post count: 5658

    Even if they have sorted it be the ColumnManagerRow/Cells, the Index property of each DataRow still represents its index in the actual DataSource. The index of the DataRows in the order in which they are sorted can be retrieved using the GetSortedDataRows method and then checking the Index of the DataRow in the returned collection.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 456 views)

    User (Old forums)
    Member
    Post count: 23064

    Wow, you guys thought of everything.

    (or, almost everything 🙂 )

    Imported from legacy forums. Posted by Buggi (had 531 views)

    Xceed Support
    Member
    Post count: 5658

    We try 😉

    Imported from legacy forums. Posted by Jenny [Xceed] (had 6431 views)

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.