473,499 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: Overide OnPaint in textBox

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
May 10 '07 #1
2 3538
On May 10, 3:13 pm, "Martin Arvidsson, Visual Systems AB"
<martin.arvids...@vsab.netwrote:
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.

May 10 '07 #2
Ok!

Thanx!

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

/Martin

"Moty Michaely" <Mo*****@gmail.comskrev i meddelandet
news:11**********************@o5g2000hsb.googlegro ups.com...
On May 10, 3:13 pm, "Martin Arvidsson, Visual Systems AB"
<martin.arvids...@vsab.netwrote:
>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.

May 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
9568
by: christian ternek | last post by:
Hello ! I want to make a custom textbox and inherit a custom control from textbox. Now i want to change the looking of the textbox with the following code: protected override void...
3
4219
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
20
2543
by: BB | last post by:
Hello all, I am trying to override OnPaint in a custom textbox control (so I can drawstring a caption, etc.). In the code below, I get the "painting the form" message as expected, but not the...
0
1378
by: Ferdinand Zaubzer | last post by:
Hello, I am trying to customize the appearance of a textbox but with overriding the onPaint Method it doesn't work! I have read that drawing of a textbox is done by Windows and not by .Net and...
4
4588
by: H-S | last post by:
Please help. This is a real puzzler! Originally posted on microsoft.public.dotnet.framework.windowsforms but no answer found! I have a read-only textBox which shows the results of a selection...
6
3713
by: Tom P. | last post by:
I'm trying to make one of our perennial favorites - The Syntax Color Editor. (Mostly as a learning exercise). I'm wondering if there is a way to capture the Paint event of a textbox so I can...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.