winform中放了一个TextBox,怎样慢慢滚动翻屏?先感谢前辈了! 环境:c#+winform+vs2008问题:在一个winform中放了一个TextBox,multiline=True。由于TextBox里边放了几千字的文本,所以想打开页面时就让TextBox慢慢滚动翻屏。 先感谢前辈了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 增加一个timer在timer的tick中,设置TextBox.SelectIndex,每次为下一行的第一个字符位置。执行TextBox的ScoreToCaste方法。 [DllImport("user32.dll", EntryPoint = "SendMessage")] public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); [DllImport("user32")] public static extern int GetScrollPos(IntPtr hwnd, int nBar); [DllImport("user32.dll")] static extern int SetScrollPos(IntPtr hWnd, int nBar,int nPos, bool bRedraw); public const int EM_LINESCROLL = 0xb6; private void timer1_Tick(object sender, EventArgs e) { int i= GetScrollPos(this.textBox1.Handle,1); SendMessage(this.textBox1.Handle, EM_LINESCROLL, 0, 1); if (i == GetScrollPos(this.textBox1.Handle, 1)) { this.textBox1.SelectionStart = 0; this.textBox1.SelectionLength = 1; this.textBox1.ScrollToCaret(); this.textBox1.SelectionLength = 0; } Console.WriteLine(i); } private void textBox1_MouseEnter(object sender, EventArgs e) { this.timer1.Stop(); } private void textBox1_MouseLeave(object sender, EventArgs e) { this.timer1.Start(); }http://topic.csdn.net/u/20080516/16/ee1e0f44-ec0a-4f46-bd36-3cbb7ec2bf17.html http://blog.csdn.net/jianuMan/archive/2010/06/19/5680535.aspx文本自动重复滚屏的例子 用c#解析RBus协议数据串 正则表达式 求救:匹配连续数字如,123,456. 页面传值问题,嘴常用的、才发现的、不能理解的、......求解释 为什么在c#中按F5程序可以正确的执行,而按ctrl+F5程序就会崩溃???? 访问IIS页面插入数据报错 这个集合编辑器该怎么做? asp.net + Oracle = 100 + ? 从txt读入string中文错误 请教一下radiobutton的问题 C# winform用pictureBox播放的两路视频要同时运行不相互干扰,多线程怎么解决? 固定区域内绘点 Type:09-DD DoD IP是什么包?
在timer的tick中,设置TextBox.SelectIndex,每次为下一行的第一个字符位置。执行TextBox的ScoreToCaste方法。
public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
[DllImport("user32")]
public static extern int GetScrollPos(IntPtr hwnd, int nBar);
[DllImport("user32.dll")]
static extern int SetScrollPos(IntPtr hWnd, int nBar,int nPos, bool bRedraw);
public const int EM_LINESCROLL = 0xb6;
private void timer1_Tick(object sender, EventArgs e)
{
int i= GetScrollPos(this.textBox1.Handle,1);
SendMessage(this.textBox1.Handle, EM_LINESCROLL, 0, 1);
if (i == GetScrollPos(this.textBox1.Handle, 1))
{
this.textBox1.SelectionStart = 0;
this.textBox1.SelectionLength = 1;
this.textBox1.ScrollToCaret();
this.textBox1.SelectionLength = 0;
}
Console.WriteLine(i);
}
private void textBox1_MouseEnter(object sender, EventArgs e)
{
this.timer1.Stop();
}
private void textBox1_MouseLeave(object sender, EventArgs e)
{
this.timer1.Start();
}
http://topic.csdn.net/u/20080516/16/ee1e0f44-ec0a-4f46-bd36-3cbb7ec2bf17.html