ImageCombos- how to use them?

  • Thread starter Thread starter D T
  • Start date Start date
D

D T

Hi,
I need some general info on ImageCombos
how do you use them? how do u put imgs into them?
can u use them as normal combos? can u do an event according to what img
the user chose?

Thanx
|DT|
 
Hi,

Here is an example.

Dim arColor() As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.DrawMode = DrawMode.OwnerDrawFixed
ComboBox1.Location = New Point(60, 60)
ComboBox1.Width = 150
ComboBox1.Visible = True
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

arColor = KnownColor.GetNames(GetType(KnownColor))
ComboBox1.Items.AddRange(arColor)
End Sub


Private Sub combobox1_DrawItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
Dim g As Graphics = e.Graphics
Dim s As String
Dim d As Date
Dim br As Brush = SystemBrushes.WindowText
Dim brBack As Brush
Dim rDraw As Rectangle
Dim bSelected As Boolean = CBool(e.State And DrawItemState.Selected)
Dim bValue As Boolean = CBool(e.State And
DrawItemState.ComboBoxEdit)

rDraw = e.Bounds
rDraw.Inflate(-1, -1)

If bSelected And Not bValue Then
brBack = Brushes.LightBlue
g.FillRectangle(Brushes.LightBlue, rDraw)
g.DrawRectangle(Pens.Blue, rDraw)
Else
brBack = Brushes.White
g.FillRectangle(brBack, e.Bounds)
End If

br = Nothing
brBack = Nothing
rDraw = Nothing

Try
s = ComboBox1.Items.Item(e.Index).ToString
Catch
s = ""
End Try

Dim x, y As Integer

x = e.Bounds.Left + 25
y = e.Bounds.Top + 1
Dim c As Color
Dim b As SolidBrush
c = Color.FromName(s)
b = New SolidBrush(c)

g.FillRectangle(b, x - 20, y + 2, 10, 10)
g.DrawString(s, ComboBox1.Font, Brushes.Black, x, y)
End Sub


Ken
 
Hi Ken,
Thanks for your reply but is not what im looking for, Sorry perhaps I
didnt explain it well enough, you see there is an component you can load
that comes with Microsoft VB 6.0 called Microsoft Windows Common
Controls 6.0 (sp6) (MsComClt.ocx). There U can find a control called
ImageCombo. I want to know how to use them.

Thanks :-)
|DT|
 
Back
Top