Results 1 to 2 of 2

Thread: User Control.

  1. #1

    Thread Starter
    Hyperactive Member Ram2Curious's Avatar
    Join Date
    Apr 2010
    Posts
    484

    User Control.

    Hi,

    Recently i found a XP Style Flat Combo Box User Control ( Please see Attachment ) but got disappointed due to its lack of .List and .List Index property. It would be very useful if someone is able to add this property to the control so that it functions like the usual combo box.

    Kindly help......

    Thanks in advance......
    Attached Files Attached Files

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: User Control.

    I'll leave it to you to append the code and take necessary steps identified below.
    That usercontrol simply uses a VB combobox, so all that is needed is to expose those properties to the user

    1. Add this to the usercontrol
    Code:
    Public Property Get ListIndex() As Integer
        ListIndex = Combo1.ListIndex
    End Property
    Public Property Let ListIndex(NewIndex As Integer)
        Combo1.ListIndex = NewIndex
    End Property
    
    Public Property Get ItemData(Index As Integer) As Long
        ItemData = Combo1.ItemData(Index)
    End Property
    Public Property Let ItemData(Index As Integer, newValue As Long)
        Combo1.ItemData(Index) = newValue
    End Property
    
    Public Property Get List(Index As Integer) As String
        List = Combo1.List(Index)
    End Property
    Public Property Let List(Index As Integer, newValue As String)
        Combo1.List(Index) = newValue
    End Property
    2. For the new ListIndex property, go to the IDE menu: Tools | Procedure Attributes and make sure, under the Advanced section, the "Don't show in property browser" checkbox is checked.

    3. Add appropriate error handling if desired to the above properties

    Edited:I just noticed. The project in the zip file already has a ListIndex property, so ignore part of what I posted above. I wouldn't anticipate anyone rewriting that project for you; you may want to give it a shot to add more features. Otherwise, just add the list items during form_load.

    You will not get the List & ItemData properties to show up in design view. To add items while in design mode, a property page will need to be created or a far more advanced workaround. If adding a property page, in order to save the list items and item data values, you don't really want to save each item as an individual property in the WriteProperties event. But VB won't allow you to save arrays except byte arrays. So... you can combine the list items, as a single string, with a delimeter & save that, then read it back during ReadProperties event and Split it to append the items to the combobox. Similar method can be used for the ItemData.
    Last edited by LaVolpe; Aug 10th, 2010 at 03:29 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width