OnGotFocus Problem

  • Thread starter Thread starter Mubashir Khan
  • Start date Start date
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);
}
 
I have used OnEnter and OnLeave too. It works fine but TextAlign property is
causing problem. Any Clues ???
 
Hi Mubashir,

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

Kind Regards,
Alex Clark
 
Back
Top