1

Is it possible to draw a shape in a textbox(not rich)?

I tried the below, but nothing seems to happen.

Protected Overloads Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
    pevent.Graphics.DrawEllipse(Pens.Black, pevent.ClipRectangle)
End Sub

The future hope is to make a textbox with a watermark type image on the side.

Connor Albright
  • 723
  • 4
  • 13
  • 29
  • 1
    You can't make it work with TextBox. There's a project that hacks around the limitations (doesn't actually use a TextBox), can't really recommend it: http://www.codeproject.com/KB/edit/alphablendtextbox.aspx – Hans Passant Sep 21 '11 at 17:38

1 Answers1

1

If you put a breakpoint in the debugger do you reach this line? I believe you need to use SetStyle(ControlStyles.UserPaint, True) before your control will call OnPaintBackground.

You may want to look at this SO answer about custom backgrounds in WinForm textboxes: Can a background image be set on a Winforms TextBox?

The short answer, is it looks like this is not easily possible due.

You may want to look at this article, as it offers some interesting approaches to custom drawn text box controls.

Community
  • 1
  • 1
LBushkin
  • 129,300
  • 32
  • 216
  • 265