programming In C# with Visual Studio 2008
Sometimes you need to add this little trick in your code to ease using it. this trick is to force the TextBox, ListBox, ListView, or DataGridView to scroll down to the last item was entered.
Here are some info on how to do an Auto-scroll for your program controls
TextBox autoscroll
textBox1.SelectionStart = textBox1.Text.Length; textBox1.ScrollToCaret();
ListBox autoscroll
listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox1.SelectedIndex = -1;
ListView autoscroll
listView1.EnsureVisible(listView1.Items.Count - 1);TreeView autoscroll
treeView1.Nodes[treeView1.Nodes.Count - 1].EnsureVisible();
DataGridView autoscroll
dataGridView1.FirstDisplayedCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];
Note:This blog was first published in Google Knowledge but since they shut down the project, I had to move my blogs here.
No comments:
Post a Comment