C# – AutoScroll

텍스트박스 등에 로그를 추가하고 나서
자동으로 마지막 입력한 내용이 보이도록 스크롤 하고 싶을때 아래와 같은 코드를 사용하시기 바랍니다.

TextBox

textBox1.SelectionStart = textBox1.Text.Length;
textBox1.ScrollToCaret();

 

ListBox

listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox1.SelectedIndex = -1;

 

ListView

listView1.EnsureVisible(listView1.Items.Count - 1);

 

TreeView

treeView1.Nodes[treeView1.Nodes.Count - 1].EnsureVisible();

 

DataGridView

dataGridView1.FirstDisplayedCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];

 

사용자 삽입 이미지

2개의 댓글

댓글 남기기