c# - How do I avoid having my Rich Text Box, "scroll bar," freeze up? -
my issue in .net framework using c# create simple form application contains rich text box (rtb) control.
briefly issue experiencing when trying clear contents (.text) of rtb, scroll bar doesn't go away. know if there inherently wrong way using rtb. apologize, site not allow me post images yet. if there misunderstanding regarding "doesn't go away" means, please ask!
so first, write data box using following code snippet:
// append new message this.rtb_receive_0.text += message; this.rtb_receive_0.selectionstart = this.rtb_receive_0.text.length; this.rtb_receive_0.scrolltocaret();
later on, clear rtb contents (rtb.text) following code:
this.rtb_receive_0.text = string.empty; this.rtb_receive_0.refresh();
in above code have attempted fix problem the, "refresh," method. not seem doing job.
when clear rtb contents, scroll bar not go away... noticed if grab window , drag on top of application, frozen scroll bar disappears. also, can minimize application, maximize again , bar disappear. there has way prevent frozen scroll bar happening in first place though.
per answer, here fix stop bar freezing up:
this.rtb_receive_0.text = string.empty; this.rtb_receive_0.clear(); this.rtb_receive_0.scrollbars = richtextboxscrollbars.none; this.rtb_receive_0.scrollbars = richtextboxscrollbars.vertical; this.rtb_receive_0.refresh();
have tried programatically setting scrollbars property on rtb?
myrichtextbox.scrollbars = richtextboxscrollbars.none;
edit: think misinterpreted needed. searching around, found similar post on forum: http://www.vbforums.com/showthread.php?793671-resolved-richtextbox-visual-bug
this user setting value of rtb based on selection in list view. when new value set , not require scrollbar doesn't re-draw , still shows bar.
it seems adding myrichtextbox.clear(); myrichtextbox.refresh();
should help. in case user programatically setting scrollbars
property well.
also, able determine how many lines of text can fit in richtextbox before scrollbar needed? suppose might vary based on system settings on machine, might able programatically check myrtb.scrollbars = (myrtb.lines.length > x) ? vertical : none;
(excuse psuedo code syntax)
Comments
Post a Comment