SendMessage(pipeTextBox.Handle, WM_VSCROLL, (
IntPtr)SB_BOTTOM, IntPtr.Zero);Textbox scroll to caret
please see code, Im trying to dynamically add three text boxes to a tabpage, i need each texbox to scroll down to the end of the page as text from a pipestream comes in, currently only the last textbox being created will do this so i presume something is being overwrote in memory but im not sure how to do tell each textbox to follow the same routine

Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 7, 2011, 7:31 AM EDT
example would be:
TextBox1.ScrollToCaret();
What is the error you are getting?
luke7 reputationPosted Oct 7, 2011, 8:00 AM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 7, 2011, 8:18 AM EDT
textbox1.ScrollToEnd();
or
textbox1.Select(textbox1.Text.Length, 0);
Sam HobbsRank #107 · 20.5K reputationPosted Oct 7, 2011, 8:13 PM EDT
So I hope you try using ScrollToCaret as Javeed suggests and that you will look for functions such as that in .Net that you can use instead of using the Windows API directly.
There are many great reasons to use the Windows API directly but .Net makes it unnecessary for most things.
luke7 reputationPosted Oct 10, 2011, 5:03 AM EDT
slightly changed approach once each textbox is dynamically created (read in from text file and iterated over) and added to a tab, am now calling an event handler with the following code, again only the textbox in the last tab (last entry read in from text file) will scroll down as text is read in all the others just remain at the top of the page and the scrollbar gets larger and i can scroll to the bottom but it isnt done automatically, is this enough info to give any advice?
private void pipeTextBox_TextChanged(object sender, EventArgs e)Control c = (Control)sender;
{
pipeTextBox.Focus();
pipeTextBox.SelectionStart = pipeTextBox.Text.Length;
pipeTextBox.ScrollToCaret();
}
public void createPipes()
{
foreach (DictionaryEntry de in pipeNames)
{
TabPage tab = new TabPage(de.Value.ToString());
pipeTextBox = new TextBox()
pipeTextBox.Name = de.Value.ToString() +
pipeTextBox.Width = 630;
pipeTextBox.Height = 470;
pipeTextBox.Multiline = true;
pipeTextBox.AcceptsReturn = true;
pipeTextBox.WordWrap = false;
pipeTextBox.ScrollBars = scrollbars.both;
pipeTextBox.ReadOnly = true
pipeTextBox.TextChanged += new System.EventHandler(this.pipeTextBox_TextChanged);
tab.Controls.Add(pipeTextBox);
PipeServer srv = new PipeServer(de.Value.ToString(), _uiSyncContext, ref temp);
pipeServers[de.Value.ToString()] = srv;
Control temp = pipeTextBox;
}
}
} }