Q: Overide OnPaint in textBox

  • Thread starter Thread starter Martin Arvidsson, Visual Systems AB
  • Start date Start date
M

Martin Arvidsson, Visual Systems AB

Hi!

I have a textBox on a windows form.

Can i overide the textbox OnPaint directly in the form, if so how.
Or do i have to inherit the textbox control and overide it there?

Regards
Martin
 
Hi!

I have a textBox on a windows form.

Can i overide the textbox OnPaint directly in the form, if so how.
Or do i have to inherit the textbox control and overide it there?

Regards
Martin

Martin,

There is no native .NET way to override the OnPaint besides inheriting
it that I know about.

You can subclass the textBox and override the WM_PAINT message using
interop services.

You can use inherit NativeWindow class and attach the window handle of
the TextBox to a it. The concrete class will override the WndProc
method and handle the WM_PAINT message in it.

Hope it helps.

Moty.
 
Ok!

Thanx!

I think the easiest way to do it by inheritance. This way it's also easy to
maintain :)

/Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top