Adding combo button on a textbox

I'd like to draw a combobox button on a textbox control (in its client area, so that the button seems to be on the right side).

I need to use it a value search function.

How can I do it

Thanks.



Answer this question

Adding combo button on a textbox

  • DavidAtPgMensys

    Try creating a UserControl. That's what they're for :)

  • Oli Green

    normaly this works:

    override the onpaint of the textbox and put this code in

    ControlPaint.DrawComboButton(e.Graphics, buttonRectangle, ButtonState.Normal)

     Buttonretangle is the retangle specifying the button location and size

    not sure about textboxes, I think there are drawn by the os instead of the framework.

    if that's the case then draw on it's hosting control

     

    Good luck

    Remco


  • tobimat80

    Yeah, it sucks

    On all kind of controls you can override the paint with the exception of textbox(and a few others)

    I had a simular 'problem' a few months ago see here: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=109945&SiteID=1

    wat you can do in this case is add a button to the textbox control cellection and dock it to the side of the textbox.

     

    Good luck


  • Schmidty6060

    The solution of adding a Button control on runtime, and dock it to the TextBox control is a good idea, and I think you should go for that.

    As for TextBox control's paint issue, yes, regular textbox doesn't trigger the OnPaint method, but it does process WM_PAINT, WM_NCPAINT and other paint related messages, and you can get this via the WndProc override. For some example on how to do this, see this thread: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=170500&SiteID=1

    Regards,

    -chris

  • lordcornholio

    I tryed overriding OnPaint method, but it doesn't work.

    I'd like to handle painting into the control like MFC.

    Any hints

    Felice


  • Blizzard

    Usercontrol is the best choose. just like comboBox .



  • Adding combo button on a textbox