Hello, i've been trying to customize the .Net combox and have a good result for DropDownList style of combobox, but i want to be able to write the input of the combobox as in DropDown style. As soon as i change the style, the textbox area stops responding to my OnPaint event.
Is it an impediment from Windows or is there a workaround to have a customized and editable combobox?
This would be my constructor
and this the function i call on my paint methodCode:Public Sub New() InitializeComponent() Me.SetStyle(ControlStyles.UserPaint _ Or ControlStyles.AllPaintingInWmPaint _ Or ControlStyles.Opaque _ Or ControlStyles.ResizeRedraw, True) Me.DrawMode = DrawMode.OwnerDrawFixed Me.m_ControlBuffer = New Bitmap(Me.Width, Me.Height) Me.m_ControlGraphics = Graphics.FromImage(m_ControlBuffer) Me.m_BackBuffer = New Bitmap(Me.Width, Me.Height) Me.m_BackGraphics = Graphics.FromImage(m_BackBuffer) Dim backcolor As Color = If(Enabled, m_UITheme.TextBoxColor, Color.White) BackgroundBrush = New SolidBrush(backcolor) End Sub
Thanks in advanceCode:Public Sub CustomPaint(screenGraphics As Graphics) ' If there is body to be drawn. If Me.Width > 0 AndAlso Me.Height > 0 Then ' Clear the background image graphics If Me.m_backImage Is Nothing Then ' Cached Background Image Me.m_backImage = New Bitmap(Me.Width, Me.Height) Dim backGraphics As Graphics = Graphics.FromImage(Me.m_backImage) backGraphics.Clear(Color.Transparent) Me.PaintTransparentBackground(backGraphics, Me.ClientRectangle) End If m_BackGraphics.Clear(Color.Transparent) m_BackGraphics.DrawImageUnscaled(Me.m_backImage, 0, 0) m_ControlGraphics.Clear(Color.Transparent) m_ControlGraphics.SmoothingMode = SmoothingMode.HighQuality ' Begin drawing Dim path As GraphicsPath = GetBoxBorder() m_ControlGraphics.FillPath(BackgroundBrush, path) PaintArrowAndLine(m_ControlGraphics) ' Draw text DrawText(m_ControlGraphics) m_ControlGraphics.Flush() m_BackGraphics.DrawImage(m_ControlBuffer, New Rectangle(0, 0, m_ControlBuffer.Width, m_ControlBuffer.Height), 0, 0, m_ControlBuffer.Width, m_ControlBuffer.Height, GraphicsUnit.Pixel) m_BackGraphics.Flush() ' Now paint this to the screen screenGraphics.DrawImageUnscaled(m_BackBuffer, 0, 0) End If End Sub




Reply With Quote
