Previous | Index | Next 

ItemData property

The ItemData property isn’t supported by the VB.NET ListBox control. Code migrated by the Upgrade Wizard uses helper methods to render this property.

Interestingly, the items of a .NET ListBox control can be objects of any type, not just strings. If an object is used, the ListBox control displays whatever the object’s ToString method returns. If you need to associate data with an item, you can just create a class that contains two items, as in this example:

        Class ListItem
            Public ItemText As String   ' what is displayed
            Public ItemData As Object   ' associated data

            Public Overrides Function ToString() As String
                Return ItemText
            End Function
        End Class

VB Migration Partner fully supports this property; migrated code works correctly even if the control is accessed in late-bound mode.

 

Previous | Index | Next