Textbox will not fire the ONPaint

  • Thread starter Thread starter christian ternek
  • Start date Start date
C

christian ternek

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 OnPaint(PaintEventArgs e)

{

....

}
But the program will not come to this event !!

Can someone help me why?

Thanks

Christian
 
Have you attached the event handler to your control

myControl += new EventHandler(OnPaint);
 
Hi Rasika,
Have you attached the event handler to your control:

myControl += new EventHandler(OnPaint);

Sorry, but i don't get what this line means?

Did you mean?:
myControl.Paint +=new PaintEventHandler(myControl_Paint); ?

But i think that Christian have inherited TextBox class
so he could access Paint event by overriding OnPaint(...)
method.

I think the "key" is that TextBox class have Paint event
hidden in events list.

I tried "OnPaintBackground" and it is not fired too.

Strange things are going in Windows.Controls... :(

Marcin
 
Yes I have inherited the TextBox!

What do you mean with
"I think the "key" is that TextBox class have Paint event hidden in events
list."
Thanks
Christian
 
Hi christian,
Yes I have inherited the TextBox!

What do you mean with
"I think the "key" is that TextBox class have Paint event hidden in events
list."
Thanks
Christian

This event does not show in event/property list of TextBox.
So, i think that Paint event can not be succesfully catched
and OnPaint method is not called, too.
So, OnPaintBackground method seems to be not called.

I think that TextBox designers implements much Paint tricks
and disables it to any inheriting usage.
I found similar problem (not with Paint) when i want to
inherits DateTimePicker control.

Regards

Marcin
 

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