views:

541

answers:

1

Hi,

I've overriden the WndProc of the ComboBox and I am drawing my own combo box, a code snippet is below:

Protected Overrides Sub WndProc(ByRef m As Message)

    MyBase.WndProc(m)
    Select Case m.Msg
        Case &HF

            Dim g As Graphics = Me.CreateGraphics

            If ComboBoxRenderer.IsSupported Then
                Dim pTextBoxRect As New Rectangle(Me.ClientRectangle.X, Me.ClientRectangle.Y, Me.ClientRectangle.Width, Me.ClientRectangle.Height)
                ComboBoxRenderer.DrawTextBox(g, pTextBoxRect, _tbState)
                 ' .... and so on
    End Select
End Sub

Though the old control is still being painted as my drawn combo box is just overlapping the old drawing. Is there a way to stop it drawing the default combo box?

Thanks, Rob

A: 

The method you are using is the only way to get it done, but you are right, it draws over the top of the default combobox, and there is no way around this while still using the combobox control.

To truly get a custom drawn combobox, you need to go up one level higher in the object tree, but then you end up having to recreate almost all of the functionality of the combobox.

Stewbob
Thanks for confirming Stewbob I did have a hunch that was going to be the case.
rob