我在textbox中加入了垂直滚动条,怎么让滚动条总是滚到textbox中内容的末尾?谢谢
不清楚.
[此贴子已经被作者于2006-6-13 18:42:18编辑过]
private float vScrolMultiplier;
private void vScrollBar1_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
vAbsPos=(float)(vScrollBar1.Value-vScrollBar1.Minimum);
SetVerticalScrollMultiplier(textBox1);
if(vScrollBar1.Value>voldValue)
{
textBox1.Top=textBox1.Top+(int)(vScrolMultiplier*vAbsPos);
}
else
{
textBox1.Top=textBox1.Top-(int)(vScrolMultiplier*vAbsPos);
}
voldValue=vScrollBar1.Value;
}
private void SetVerticalScrollMultiplier(Control ctrl)
{
float hsb=(float)(vScrollBar1.Maximum-ctrl.Height);
float ticks=(float)(vScrollBar1.Maximum-vScrollBar1.Minimum);//
vScrolMultiplier=hsb/ticks;
}