vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
SEPA-Dateien erstellen inkl. IBAN-, BLZ-/Kontonummernprüfung  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2024
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Fortgeschrittene
Re: ComboBox in FlatStyle 
Autor: ModeratorDaveS (Moderator)
Datum: 06.01.05 20:21

Wenn ich mir das anschaue..naja, ist ziemlich schlampig programmiert und da könnte man noch einiges verbessern, leider habe ich nur Zeit für einen schnellen Fix, was aber vielleicht eher das ist was du willst
Public Class FlatCombo
    Inherits ComboBox
 
    Private BorderPen = New Pen(SystemColors.ControlDarkDark, 1)
    Private BorderBrush As Brush = New SolidBrush(SystemColors.Window)
    Private ArrowBrush As Brush = New SolidBrush(SystemColors.ControlText)
    Private DropButtonBrush As Brush = New SolidBrush(SystemColors.Control)
    Private _ButtonColor As Color = SystemColors.Control
 
    Public Property ButtonColor() As Color
        Get
            Return _ButtonColor
        End Get
        Set(ByVal Value As Color)
            _ButtonColor = Value
            DropButtonBrush = New SolidBrush(Me.ButtonColor)
            Me.Invalidate()
        End Set
    End Property
 
    Dim borderWidth As Integer = 1
 
    Protected Overrides Sub WndProc(ByRef m As Message)
        MyBase.WndProc(m)
 
        Select Case m.Msg
            Case &HF
                'Paint the background. Only the borders
                'will show up because the edit
                'box will be overlayed
                Dim g As Graphics = Me.CreateGraphics
                'Dim p As Pen = New Pen(Color.White, 2)
                g.FillRectangle(BorderBrush, Me.ClientRectangle)
 
                ' Draw the border
                Debug.WriteLine(Me.ClientRectangle.ToString())
                g.DrawRectangle(BorderPen, 0, 0, Me.ClientRectangle.Width - 1, _
                  Me.ClientRectangle.Height - 1)
 
                'Draw the background of the dropdown button
                Dim rect As Rectangle = New Rectangle(Me.Width - 15, 1, 14, _
                  Me.Height - 2)
                g.FillRectangle(DropButtonBrush, rect)
 
                'Create the path for the arrow
                Dim pth As Drawing2D.GraphicsPath = New Drawing2D.GraphicsPath
                Dim TopLeft As PointF = New PointF(Me.Width - 13, (Me.Height - _
                  5) / 2)
                Dim TopRight As PointF = New PointF(Me.Width - 6, (Me.Height - _
                5) / 2)
                Dim Bottom As PointF = New PointF(Me.Width - 9, (Me.Height + 2) _
                / 2)
                pth.AddLine(TopLeft, TopRight)
                pth.AddLine(TopRight, Bottom)
 
                g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
 
                'Determine the arrow's color.
                If Me.DroppedDown Then
                    ArrowBrush = New SolidBrush(SystemColors.HighlightText)
                Else
                    ArrowBrush = New SolidBrush(SystemColors.ControlText)
                End If
 
                'Draw the arrow
                g.FillPath(ArrowBrush, pth)
 
            Case Else
                Exit Select
        End Select
    End Sub
 
    'Override mouse and focus events to draw
    'proper borders. Basically, set the color and Invalidate(),
    'In general, Invalidate causes a control to redraw itself.
#Region "Mouse and focus Overrides"
    Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
        MyBase.OnMouseEnter(e)
        Me.Invalidate()
    End Sub
 
    Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
        MyBase.OnMouseLeave(e)
        If Me.Focused Then Exit Sub
        Me.Invalidate()
    End Sub
 
    Protected Overrides Sub OnLostFocus(ByVal e As System.EventArgs)
        MyBase.OnLostFocus(e)
        Me.Invalidate()
    End Sub
 
    Protected Overrides Sub OnSelectedIndexChanged(ByVal e As System.EventArgs)
        MyBase.OnSelectedIndexChanged(e)
        Me.Invalidate()
    End Sub
 
#End Region
 
End Class

________
Alle Angaben ohne Gewähr. Keine Haftung für Vorschläge, Tipps oder sonstige Hilfe, falls es schiefgeht, nur Zeit verschwendet oder man sonst nicht zufrieden ist

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
ComboBox in FlatStyle2.175Fritz06.01.05 15:44
Re: ComboBox in FlatStyle1.714ModeratorDaveS06.01.05 16:29
Re: ComboBox in FlatStyle1.610Fritz06.01.05 17:54
Re: ComboBox in FlatStyle2.135ModeratorDaveS06.01.05 20:21
Re: ComboBox in FlatStyle1.637Fritz06.01.05 20:59
Re: ComboBox in FlatStyle1.543ModeratorDaveS06.01.05 21:13
Re: ComboBox in FlatStyle1.441Fritz06.01.05 21:05
Re: ComboBox in FlatStyle1.498Fritz06.01.05 21:38
Re: ComboBox in FlatStyle1.534ModeratorDaveS06.01.05 21:46
Re: ComboBox in FlatStyle1.549Fritz06.01.05 22:00
Re: ComboBox in FlatStyle684Deckelmaho09.11.20 09:45

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2024 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel