Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Elegant Ribbon Tech Support » Add Images / Screentip to a ComboBox item Collapse All
Subject Author Date
Gunter Avenius Mar 6, 2008 - 2:17 AM

Hello,

Elegant Ribbon 3.0, vb2005

How can i add a Comobox Item with Screentip an Image with Code in vb2005.
The Images are store in a Imagelist.

I can add a Combobox Item without Image and Screentip with:

ComboBoxControl.Items.Add("MyCombobox")

Thanks
Gunter

Gunter Avenius Mar 6, 2008 - 11:19 PM

Hello,

I found it.

Comboboxcontrol.Items.Add(New ComboboxItem("Name",Image,"Screentip"))

Thanks.
Gunter

Gunter Avenius Mar 6, 2008 - 9:56 AM

Hello,

Please, can you give me a litte example for vb2005?

Thanks.
Gunter

Technical Support Mar 6, 2008 - 9:51 AM

If you need to modify combo box items collection dynamically, you should work with the ComboBox.Items collection directly instead of setting DataSource. In this case all you need is to add an items to this collection in a button click event handler.

Gunter Avenius Mar 6, 2008 - 6:16 AM

Hello,

thanks.

I found the sample Code in our Samples.

Ok. This Sample adds 2 ComboboxItems and works fine.

How can i add with a Button Click another (third) Combobox Item?

Text ="Item 3"
Screentip = "My next ComboBoxitem"
Image=imgList1.Images("myImage")

Technical Support Mar 6, 2008 - 6:08 AM

You can add images and tooltips for a combo box items by using the ComboBox.ItemImagePropertyName and ComboBox. ItemScreentipTextPropertyName properties, like as follows

            Friend Class ComboBoxItem
      Public Sub New(ByVal text As String, ByVal image As Image, ByVal tooltipText As String)
            _Text = text
            _Image = image
            _ScreentipText = tooltipText
      End Sub

      Public _Text As String

      Public Property Text() As String
            Get
                 Return _Text
            End Get
            Set(ByVal value As String)
                 _Text = value
            End Set
      End Property

      Public _ScreentipText As String

      Public Property ScreentipText() As String
            Get
                 Return _ScreentipText
            End Get
            Set(ByVal value As String)
                 _ScreentipText = value
            End Set
      End Property

      Public _Image As Image

      Public Property Image() As Image
            Get
                 Return _Image
            End Get
            Set(ByVal value As Image)
                 _Image = value
            End Set
      End Property
End Class

Private Sub InitializeComboBoxWithImages()
      Dim ds() As ComboBoxItem = { New ComboBoxItem("Item 1", myImage1, "Item 1 Description"), _
                                        New ComboBoxItem("Item 2", myImage2, "Item 2 ) }

      SampleComboBoxWithImages.ItemImagePropertyName = "Image"
      SampleComboBoxWithImages.ItemScreentipTextPropertyName = "ScreentipText"
      SampleComboBoxWithImages.DisplayMember = "Text"
      SampleComboBoxWithImages.ItemHeight = 40
      SampleComboBoxWithImages.DataSource = ds
End Sub