DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2007
    Posts
    38

    Combobox with images and text

    Hi,

    I'm trying to do a combobox containing items wich are made of a image and some text following it, for example, like that one in Autocad to selec the layer, wich is shown in the appended image.

    I have the code to insert images, but not to insert items with both images and text.

    Thanks
    Attached Images
    Attached Files

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,652
    Have a look here
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Nov 2007
    Posts
    38
    Hi,

    Thanks for the reply. I have taken a look and downloaded the zip fie. I've opened the project and i see too much code and don't understand what is it and how can i use it.

    can you help me a bit more?

    Thanks

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,652
    Quote Originally Posted by mqdias
    I have taken a look and downloaded the zip fie. I've opened the project and i see too much code
    That doesn't surprise me. What you ask isn't easy.
    Quote Originally Posted by mqdias
    can you help me a bit more?
    Sure. If you have specific questions, I'll take a shot at them.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Nov 2007
    Posts
    38
    Hi,

    Maybe i'll insert the text i want directly in the image, so that i can use the code that i have already to list images.

    But, with the code that i've attached in a doc, you see any way i can add some few more code to add text aside to the images, please tell me.

    Thanks anyway!!!

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,652
    Code from the document (unless there is so much code that it won't fit in a post, it makes better sense to just post it rather than attach with something.)
    Code:
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            Dim items(Me.ImageList1.Images.Count - 1) As String
            For i As Int32 = 0 To Me.ImageList1.Images.Count - 1
                items(i) = "Item " & i.ToString
            Next
    
            Me.ComboBox1.Items.AddRange(items)
            Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
            Me.ComboBox1.DrawMode = DrawMode.OwnerDrawVariable
            Me.ComboBox1.ItemHeight = Me.ImageList1.ImageSize.Height
            Me.ComboBox1.Width = Me.ImageList1.ImageSize.Width + 50
            Me.ComboBox1.MaxDropDownItems = Me.ImageList1.Images.Count
    
        End Sub
        Private Sub ComboBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
    
            If e.Index <> -1 Then
                e.Graphics.DrawImage(Me.ImageList1.Images(e.Index) _
             , e.Bounds.Left, e.Bounds.Top)
            End If
        End Sub
    
        Private Sub ComboBox1_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles ComboBox1.MeasureItem
            e.ItemHeight = Me.ImageList1.ImageSize.Height
            e.ItemWidth = Me.ImageList1.ImageSize.Width
        End Sub
    End Class
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  7. #7
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,652
    Where is the text that you want associated with the images stored?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  8. #8
    Join Date
    Nov 2007
    Posts
    38
    That code is to show add images as combobox items. It doesn't have text, but i would like to insert some, after each image, as it's showed in the attached image.

  9. #9
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,652
    Quote Originally Posted by Hack
    Have a look here
    I think it would be worth the effort to go through this code and see if you can get it to work for you.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Adding 2 images into rich text box using clib board method
    By Slatibartfast in forum VB Classic
    Replies: 2
    Last Post: 01-22-2007, 04:59 PM
  2. Replies: 0
    Last Post: 04-18-2006, 12:24 AM
  3. Loading Images into JavaScript.
    By Scott in forum Web
    Replies: 1
    Last Post: 10-31-2002, 07:44 PM
  4. swap images with text
    By LG in forum Enterprise
    Replies: 3
    Last Post: 11-05-2001, 03:30 PM
  5. How to swap text dynamically
    By Mediocrates in forum Web
    Replies: 0
    Last Post: 03-17-2001, 10:36 AM

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links