开发者

Drawing shapes in textboxes

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜