P
PeterB
If I override the OnKeyDown event and insert a case where a hyphen (minus
sign) is inserted in the textbox if 'n' is pressed, the cursor jumps from
the current position to the beginning of the textbox, writes the hyphen and
then back to the original position:
//Add Hyphen
this.Text = this.Text.Insert(0,"-");
this.SelectionStart = iCurrCaretPos + 1;
This causes some not very wanted flicker, and in my desperate attempts to
remove this I first thought of overriding the OnPaint method. In the OnPaint
event, I check a variable (_bPaint) to see if I should call base.OnPaint or
not. I set this variable to false while moving the caret around and true
whenever I'm not manipulating text in this matter
_bPaint = false;
this.Text = this.Text.Insert(0,"-");
this.SelectionStart = iCurrCaretPos + 1;
_bPaint = true;
protected override void OnPaint(PaintEventArgs e)
{
if( _bPaint )
base.OnPaint (e);
}
But OnPaint doesn't seem to be called during textchanges in the textbox
(breakpoint is never reached), or am I doing something wrong here?
Is there a way to prevent any changes to the textbox to be visible until all
operations has finished (prevent flicker).
Thanks,
Peter
sign) is inserted in the textbox if 'n' is pressed, the cursor jumps from
the current position to the beginning of the textbox, writes the hyphen and
then back to the original position:
//Add Hyphen
this.Text = this.Text.Insert(0,"-");
this.SelectionStart = iCurrCaretPos + 1;
This causes some not very wanted flicker, and in my desperate attempts to
remove this I first thought of overriding the OnPaint method. In the OnPaint
event, I check a variable (_bPaint) to see if I should call base.OnPaint or
not. I set this variable to false while moving the caret around and true
whenever I'm not manipulating text in this matter
_bPaint = false;
this.Text = this.Text.Insert(0,"-");
this.SelectionStart = iCurrCaretPos + 1;
_bPaint = true;
protected override void OnPaint(PaintEventArgs e)
{
if( _bPaint )
base.OnPaint (e);
}
But OnPaint doesn't seem to be called during textchanges in the textbox
(breakpoint is never reached), or am I doing something wrong here?
Is there a way to prevent any changes to the textbox to be visible until all
operations has finished (prevent flicker).
Thanks,
Peter