Results 1 to 6 of 6

Thread: Custom ComboBox with editable text possible?

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2020
    Posts
    11

    Custom ComboBox with editable text possible?

    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
    Code:
    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
    and this the function i call on my paint method


    Code:
    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
    Thanks in advance
    Last edited by Wardo; Jun 3rd, 2020 at 02:05 PM. Reason: Grammar

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width