Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combobox in dropdownlist mode blues
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Combobox in dropdownlist mode blues
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Jet/Access Engine
Application:
Desktop
Divers
Thread ID:
01591216
Message ID:
01591216
Vues:
56
Update : a workable solution is here : http://stackoverflow.com/questions/3789596/combobox-appearance

The trick seems to be to set the DrawMode property to OwnerDrawFixed and then to add this method in vB.Net (translated and included straight from the link above)
    Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
        e.DrawBackground()
        If e.State = DrawItemState.Focus Then
            e.DrawFocusRectangle()
        End If
        Dim index = e.Index
        If index < 0 OrElse index >= Items.Count Then
            Return
        End If
        Dim item = Items(index)
        Dim text As String = If((item Is Nothing), "(null)", item.ToString())
        Using brush = New SolidBrush(e.ForeColor)
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit
            e.Graphics.DrawString(text, e.Font, brush, e.Bounds)
        End Using
    End Sub
When one sets the DropDownStyle property of a combobox control to DropDownList, the system (from windows 7 on, not sure I had this problem in Vista) changes the appearance of the field, so that it somehow reminds one of a command button.

I definitely need the DropDownList behavior, but I'd like to have a free hand in setting the backcolor. I tweaked the drawmode property, but then the values are not displayed anymore.

So is there a quick fix to this, or do I have to code the dropdownlist behaviour to work around this?

Many thanks and happy New Year.

Marc

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Répondre
Fil
Voir

Click here to load this message in the networking platform