c# - TextBox.AppendText() not autoscrolling -


i tried following textbox text automatically scroll:

the steps using pretty trivial:

  1. drag textbox onto form.
  2. change textbox multiline.
  3. add vertical scroll.
  4. use appendtext() add text textbox.

the text not automatically scroll, despite trying solutions mentioned here:

how automatically scroll bottom of multiline text box?

what cause , how fix it?

update: if create button , use call appendtext() desired behavior. however, if try call appendtext form's constructor or load() event appended text textbox not scroll. not duplicate question haven't seen post problem in past.

since form isn't quite ready during constructor , load event, had use task scroll after becomes ready:

here method gets invoked:

void scroll() {     this.invoke(new methodinvoker(delegate()         {             textbox1.selectionstart = textbox1.text.length;             textbox1.scrolltocaret();         })); } 

it gets invoked via task placed in load event:

task task1 = new task(new action(scroll));             task1.start(); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -