Note that there are some explanatory texts on larger screens.

plurals
  1. POAvoid Label Blinking Using Timer Control
    primarykey
    data
    text
    <p>im working on a code-editor (winforms)</p> <p>and im working on countline using a label something like this:</p> <p><a href="http://oi42.tinypic.com/iypoub.jpg" rel="nofollow">http://oi42.tinypic.com/iypoub.jpg</a></p> <p>using this code:</p> <pre><code>private void timer_countline_Tick(object sender, EventArgs e) { updateNumberLabel(); } private void updateNumberLabel() { //we get index of first visible char and number of first visible line Point pos = new Point(0, 0); int firstIndex = rtb.GetCharIndexFromPosition(pos); int firstLine = rtb.GetLineFromCharIndex(firstIndex); //now we get index of last visible char and number of last visible line pos.X = ClientRectangle.Width; pos.Y = ClientRectangle.Height; int lastIndex = rtb.GetCharIndexFromPosition(pos); int lastLine = rtb.GetLineFromCharIndex(lastIndex); //this is point position of last visible char, we'll use its Y value for calculating numberLabel size pos = rtb.GetPositionFromCharIndex(lastIndex); //finally, renumber label numberLabel.Text = ""; for (int i = firstLine; i &lt;= lastLine + 1; i++) { numberLabel.Text += i + 1 + "\n"; } } </code></pre> <p>timer set interval to 1 . label dock = left . now the problem was everytime i runs the program the label was blinking nonstop so fast . even i change interval still the same thing .</p> <p>but when i transfer the updateNumberLabel() to textchange event it still blinks everytime i add a char on richtextbox or i press space .</p> <p>like this: <a href="http://oi40.tinypic.com/a43gcy.jpg" rel="nofollow">http://oi40.tinypic.com/a43gcy.jpg</a></p> <p>now my question was how can i avoid this? or is there anyway i can do to avoid blinking of the whole label when gets updated?</p> <p>thanks a lot in advance for the help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload