Wednesday, 15 August 2012

winforms - Scroll into a RichTextBox using buttons c# -



winforms - Scroll into a RichTextBox using buttons c# -

how can code 2 buttons scrolling richtextbox , downwards ? seek :

private void btnscrolltop_click(object sender, eventargs e) { if (rtbdefinitie.selectionstart >= 30) { rtbdefinitie.selectionstart -= 30; rtbdefinitie.scrolltocaret(); } } private void btnscrollbottom_click(object sender, eventargs e) { if (rtbdefinitie.selectionstart <= 30) { rtbdefinitie.selectionstart += 30; rtbdefinitie.scrolltocaret(); } }

but it's seems stuck after press scroll downwards button twice. need ?

the sec click seems interpreted doubleclick, register event , set same code behind (or replace 30 60)

edit: if application stucks, because it's working , not have time update gui, seek phone call application.doevents(); after every raised clickevent:

private void btnscrollbottom_click(object sender, eventargs e) { if (rtbdefinitie.selectionstart <= rtbdefinitie.textlength) { rtbdefinitie.selectionstart += 30; rtbdefinitie.scrolltocaret(); application.doevents(); } }

c# winforms

No comments:

Post a Comment