OnGotFocus Problem

M

Mubashir Khan

I am deriving a class from TextBox to implement a NumericBox. I am
overriding OnGotFocus and OnLostFocus methods but On GotFocus is causing
problems. Actually the commented lines are causing problems. These throw
Win32 exception that windows was unable to create handle. I dunno wats
wrong. Plz help

protected override void OnGotFocus(EventArgs e)
{
//this.TextAlign=HorizontalAlignment.Left;
//this.SelectionStart=base.Text.Length;
base.OnGotFocus(e);
}

protected override void OnLostFocus(EventArgs e)
{
this.TextAlign=HorizontalAlignment.Right;
base.OnLostFocus(e);
}
 
M

Mubashir Khan

I have used OnEnter and OnLeave too. It works fine but TextAlign property is
causing problem. Any Clues ???
 
A

Alex Clark

Hi Mubashir,

Try calling the base method first, then alter alignment properties etc.

Kind Regards,
Alex Clark
 

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

Top