Hey guys,
I've got a combobox control (Winforms) which I've set to "Drop Down List" style (because I don't want the user to be able to type text in the combobox). That works great, but I don't particularly care for the way it looks (I'd rather it look just like a regular combobox style, yet have the functionality of the "drop down list" style).
So I set the drawmode property to "ownerdrawfixed", so that I could make it look like a regular combobox. Here's the code I used for that...
^ Only thing I don't like about that is, that once a combobox item has been selected by the user and the combobox has been closed, the top part of the combobox retains that "selected" look (blue background / white text). I would rather the top part have the "non-selected" look after the combobox closes (white background / black). I think it looks a lot nicer that way.
So what I've tried so far is... immediately after the combobox is closed, I set the focus to another control on the form, like so...
That works... except when I do that, there's a bit of a "flicker" from the top part of the combox box ("flicker" meaning, it briefly flashes the blue background / white text in the top part of the combobox right before the focus moves to another control). Which doesn't look all that professional. :(
If there was a "JustBeforeDropDownCloses" event, that would be perfect -- but there's not.
So my question is... any ideas for getting rid of this flicker? I tried suspend layout / resume layout, to no avail.
I almost think it's a bit crazy to spend so much time on a stupid combobox, but I really like to have a nice, clean looking GUI that functions smoothly :)
I've got a combobox control (Winforms) which I've set to "Drop Down List" style (because I don't want the user to be able to type text in the combobox). That works great, but I don't particularly care for the way it looks (I'd rather it look just like a regular combobox style, yet have the functionality of the "drop down list" style).
So I set the drawmode property to "ownerdrawfixed", so that I could make it look like a regular combobox. Here's the code I used for that...
Code:
Private Sub ComboBox1_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
Dim TextBrush As Brush = Nothing
If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
TextBrush = Brushes.White
Else
TextBrush = Brushes.Black
End If
Dim index As Integer = If(e.Index >= 0, e.Index, 0)
e.DrawBackground()
e.Graphics.DrawString(ComboBox1.Items(index).ToString(), e.Font, TextBrush, e.Bounds, StringFormat.GenericDefault)
End Sub
^ Only thing I don't like about that is, that once a combobox item has been selected by the user and the combobox has been closed, the top part of the combobox retains that "selected" look (blue background / white text). I would rather the top part have the "non-selected" look after the combobox closes (white background / black). I think it looks a lot nicer that way.
So what I've tried so far is... immediately after the combobox is closed, I set the focus to another control on the form, like so...
Code:
Private Sub ComboBox1_DropDownClosed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.DropDownClosed
Panel1.Focus()
End Sub
If there was a "JustBeforeDropDownCloses" event, that would be perfect -- but there's not.
So my question is... any ideas for getting rid of this flicker? I tried suspend layout / resume layout, to no avail.
I almost think it's a bit crazy to spend so much time on a stupid combobox, but I really like to have a nice, clean looking GUI that functions smoothly :)