Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Override OnEnter to disable formatting onenter text but breaks Data Binding

$
0
0
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

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>