הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Saturday, August 25, 2012 3:22 PM
Hi,
how can I change the backcolor of a selected item in a listbox, without having to redraw the control (also ownerdrawmode is normal).
Somewhere I found a winapi solution, but I can't find it anymore.
All replies (6)
Saturday, August 25, 2012 5:09 PM ✅Answered | 1 vote
yes, I mean the highlight color.
I can change this, if I set the drawmode to ownerdrawfixed. But I want to have the drawmode normal.
When a moderator combines your duplicate post with this one, someone will address your problem.
Saturday, August 25, 2012 4:11 PM
Not sure what you mean by "ownerdrawmode is normal", but if DrawMode is one of the OwnerDraw options, you should be able to draw the selected item anyway you want.
Saturday, August 25, 2012 4:30 PM
When you say "back color" of a selected item, Are you meaning to say the text highlight color?
If you want something you've never had, you need to do something you've never done.
Saturday, August 25, 2012 5:06 PM
yes, I mean the highlight color.
I can change this, if I set the drawmode to ownerdrawfixed. But I want to have the drawmode normal.
Sunday, August 26, 2012 8:57 AM
I decided to use the drawitem method. I must give up.
Sunday, August 26, 2012 5:47 PM
hi DerStauner
this code maybe help you
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If ListBox1.SelectedIndex = 0 Then
ListBox1.BackColor = Color.Aqua
ElseIf ListBox1.SelectedIndex = 1 Then
ListBox1.BackColor = Color.Red
Else
....
End If
End Sub
Best Regard Fatemeh AmirAfshar