Binding a combobox to a generic.dictionary
Hi all, I am using vb.net and would like to bind a combobox to a generic dictionary object, called 'dicFriendData'. The object uses a string as it's key and a simple class, called FriendData, as the value. The relevant code is this:
I've gone through the visual design tools and attempted to create a data binder through the properties window DataBindings interface, but no matter how I set the SelectedItem and SelectedValue properties, I get no data. Anyone know how to make this work?
Public Class dicFriendData
Inherits Generic.Dictionary(Of String, FriendData)
Friend Shadows Sub Add(ByVal key As String, ByVal value As FriendData)
Friend Shadows Function Remove(ByVal key As String)
Remove = MyBase.Remove(key)
Public Class FriendData
Private _FID As String
Private _ProfileName As String
Private _IMG As Image
Public Sub New(ByVal FID As String, ByVal ProfileName As String, ByVal IMG As Image)
_FID = FID
_ProfileName = ProfileName
_IMG = IMG
Public ReadOnly Property DefaultImage() As Image
DefaultImage = _IMG
Public ReadOnly Property FriendID() As String
FriendID = _FID
Public ReadOnly Property Title() As String
Title = _ProfileName
I would appreciate help greatly!
n.b. I am not going through a database or utilizing a DB in any way, so all code I have found relating to this feature doesn't seem to help; however, the documentation, and not to mention the "Add Project DataSource" wizard, lead me to believe I can bind to an object that is not actually a DB. I've seen some brilliant and elegant solutions on this site, so I'm hoping someone can help me as well.
Try implementing the ICollections interface, or the Ienumerable interface.
rupakguha, thx for the suggestion, but can you be more specific? How would implementation of either interface allow me to bind the dictionary to the combobox?
To bind an object to a combobox the object should implement atleast one of these interfaces. If you implement either of the interfaces in your class you would be able to bind it.
By Robert R. in forum VB Classic
Last Post: 02-04-2010, 09:23 AM
By software_develo in forum .NET
Last Post: 08-07-2006, 10:31 PM
By Stan Shankman in forum .NET
Last Post: 09-07-2001, 03:06 AM
By Dharmesh in forum .NET
Last Post: 08-13-2001, 02:30 PM
By email@example.com in forum VB Classic
Last Post: 02-20-2001, 01:23 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center