Programming In C# with Visual Studio
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 auto-scroll
textBox1.SelectionStart = textBox1.Text.Length; textBox1.ScrollToCaret();
ListBox auto-scroll
listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox1.SelectedIndex = -1;
ListView auto-scroll
listView1.EnsureVisible(listView1.Items.Count - 1);TreeView autoscroll
treeView1.Nodes[treeView1.Nodes.Count - 1].EnsureVisible();
DataGridView auto-scroll
dataGridView1.FirstDisplayedCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];
No comments:
Post a Comment