Tag for the ComboBox

Posted on 2006-04-16
Last Modified: 2013-11-19
Hello, how do i set a tag for the combo box?
Question by:wd006451
    LVL 62

    Expert Comment

    by:Fernando Soto
    Hi wd006451;

    The tag property of a control holds an Object. So to assign an object to the ComboBox.Tag you can do it this way:

        ComboBox1.Tag = "Hello World"

    to get the Object out you would do this:

        Dim str As String = CType(ComboBox1.Tag, String)

    If the Tag property can holds any type

        ComboBox1.Tag = TheObjectToStore

    to get the Object out you would do this:

        Dim str As TheObjectToStore= CType(ComboBox1.Tag, TheObjectToStore)

    I hope that this is of some help.

    LVL 1

    Author Comment

    Actually, i want it actually for an item that is in the combo box, so each item will have its own tag, i can make it work for a listbox, etc... but i can't figure it out for this one....

        Dim folderDataInfo() As cFolderData
        Dim i As Integer = 0
        folderDataInfo = serverConnection.GetFoldersForUser(currentLoggedInUserData.ID)

        Me.cmbFolders.Items.Add("  -- SELECT ONE --")
        For i = 0 To folderDataInfo.Length - 1

          me.cmbfolders.items(i).folderDataInfo(i).ID() '<---- Not working...
        Me.cmbFolders.SelectedIndex = 0
    LVL 62

    Accepted Solution

    Hi wd006451;

    The ComboBox does not have a ValueMember for each item in the list as the ListBox does and therefore this is not possible unless you create you own version of the ComboBox as a user control.

    LVL 1

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
    JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now