Override OnEnter to disable formatting onenter text but breaks Data Binding

  • Thread starter Thread starter Djramc
  • Start date Start date
D

Djramc

Guest
public class CustomTextBox
{

protected override void OnEnter(EventArgs e)
{

if (this.DataBindings.Count > 0)
{
this.cancelvalidating = true;
this.DataBindings[0].FormattingEnabled = false;
this.cancelvalidating = false;
}

OldText = this.Text;
base.OnEnter(e);
}

protected override void OnLeave(EventArgs e)
{
if (this.DataBindings.Count > 0)
{
this.cancelvalidating = true;
this.DataBindings[0].FormattingEnabled = true;
this.cancelvalidating = false;
}
base.OnLeave(e);
}


}
when you enter the binded textbox format should disappear and onleave should the text again formatted. when I try this code databinding breaks

Continue reading...
 
Back
Top