DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Binding a combobox to a generic.dictionary

  1. #1
    Join Date
    Aug 2006

    Question Binding a combobox to a generic.dictionary

    Hi all, I am using 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:

    Imports System.Collections
    Public Class dicFriendData
        Inherits Generic.Dictionary(Of String, FriendData)
        Friend Shadows Sub Add(ByVal key As String, ByVal value As FriendData)
            MyBase.Add(key, value)
        End Sub
        Friend Shadows Function Remove(ByVal key As String)
            Remove = MyBase.Remove(key)
        End Function
    End Class
    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
        End Sub
        Public ReadOnly Property DefaultImage() As Image
                DefaultImage = _IMG
            End Get
        End Property
        Public ReadOnly Property FriendID() As String
                FriendID = _FID
            End Get
        End Property
        Public ReadOnly Property Title() As String
                Title = _ProfileName
            End Get
        End Property
    End Class
    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?
    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.

  2. #2
    Join Date
    Aug 2006
    Try implementing the ICollections interface, or the Ienumerable interface.

  3. #3
    Join Date
    Aug 2006
    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?

  4. #4
    Join Date
    Aug 2006
    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.

Similar Threads

  1. early/late binding DAO
    By Robert R. in forum VB Classic
    Replies: 4
    Last Post: 02-04-2010, 10:23 AM
  2. data binding with ComboBox ( DropDown List Box )
    By software_develo in forum .NET
    Replies: 0
    Last Post: 08-07-2006, 10:31 PM
  3. comboBox question
    By Stan Shankman in forum .NET
    Replies: 2
    Last Post: 09-07-2001, 03:06 AM
  4. ComboBox Binding
    By Dharmesh in forum .NET
    Replies: 1
    Last Post: 08-13-2001, 02:30 PM
  5. ComboBox Value Disappeared Automatically
    By in forum VB Classic
    Replies: 0
    Last Post: 02-20-2001, 02:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center