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
2114
DataSource and Band Rows
posted

In order to fill-in a WinGrid I do the following

source = (UltraDataSource) myGrid.DataSource
myObjCollection = GetMyObjCollection()
Dim row(source.Band.Columns.Count - 1) As Object

Foreach myObj in myObjCollection
    i = 0
    row(i++) = myObj.myProperty1
    row(i++) = myObj.myProperty2
    ...
    Dim uRow = source.Rows.Add(False, row, False)
    uRow.Tag = myObj

Next myObj

Now we have a lot of rows in the grid filled with data of myObjCollection.

So, once some of my rows are selected by user, I want to recuperate the BO from the rows tags,

I use:

Foreach row in myGrid.Selected.Rows
    row.Tag = Nothing ' WHY? How to recuperate the DataSource Row Tag value?

 

PS. Actually I do it like this:

      For Each row In grdResult.Selected.Rows
        Dim mySourceRow = TryCast(row.ListObject, UltraDataRow)
        If mySourceRow IsNot Nothing Then
          Dim myObj = TryCast(mySourceRow.Tag, MyObjClass)
          If myObj IsNot Nothing Then
            myObj.Selected = True
          End If
        End If
      Next row

But perhaps there is a more elegant way to do it...

Parents Reply Children
No Data