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
  • 469350
    Offline posted

    Hi,

    I'm having a hard time understanding what this code is doing. It doesn't make a lot of sense. You seem to be creating an array of rows, but you are using the number of Columns as the count of the array instead of the number of rows in the data source. I'm also not really sure what the point of the array is, since you are filling it with properties of your data source, but then you are not doing anything else with it.

    You have a counter here (i), which is incremented, but not defined or used anywhere else. Your 'next' statement doesn't match up to your 'Foreach'. And I don't know what 'v' is so I don't understand what you are assigning to the row's Tag.

    It looks like maybe you are assigning 'v', whatever it is, so the Tag of the row in the UltraDataSource, and then you are reading the tag of the UltraDataSource row, so it seems like that should work.

    But the code you posted here is so incomplete and jumbled, that I really can't make much out of it.

     

Reply Children