views:

41

answers:

1

I am using a DrawItem and MeasureItem events to paint a combobox with a DrawMode of OwnerDrawVariable.

Basically, I'm trying to have the user highlight a selection with the mouse, and then press the space bar to toggle the Save status of a song list. Then I call the Me.Refresh() event for the form in an attempt to redraw the form and the ComboBox.

The problem that I am running into is that only the Combobox itself (not the drop-down area) that is a control on the main form is redrawing, and the text that is behind the mouse-highlighted selection of the drop-down list is not changing from Red to Black as I believe it should. If I move the mouse to another selection, then the color does in fact update.

Here is a snippet of the code.

    If (e.KeyCode = Keys.Space) Then
        If cmbList.SelectedItem IsNot Nothing Then
            With DirectCast(cmbList.SelectedItem, SongTitle)
                .bSave = Not .bSave
            End With
        End If
    End If

    e.Handled = True

    Me.Refresh()

Thanks for any help you can provide.

A: 

You need to use .RefreshItem/.RefreshItems instead of .Refresh. See this question: http://stackoverflow.com/questions/1064109/dynamically-changing-the-text-of-items-in-a-winforms-combobox

danbystrom