Excel VBA TextBox控件的滚动条不能刷新
2015-06-18 16:04
579 查看
问题:Excel中Textbox控件以及Form里的Textbox控件,当直接填充的内容很长时,滚动条不能实时刷新。
现象:
修改后:
原因:
虽然已经向Textbox的Text里设置了内容,但此时Textbox并没有被激活,焦点也没有变化,所以,Textbox的滚动条没有被刷新出来。
修改后的VBA程序:
-----------------------ActiveX Textbox--------------------------
-----------------------Form Textbox--------------------------
知识点:
ActiveX Textbox中的 TextBox1.Activate 和 Form Textbox的 TextBox1.SetFocus功能相同
现象:
修改后:
原因:
虽然已经向Textbox的Text里设置了内容,但此时Textbox并没有被激活,焦点也没有变化,所以,Textbox的滚动条没有被刷新出来。
修改后的VBA程序:
-----------------------ActiveX Textbox--------------------------
Private Sub CommandButton1_Click() TextBox1.Value = "safdasfgsdfgfhfgjhfjfghjfhjfg" _ & Chr(10) _ & "1234567890" _ & Chr(10) ' IF the text length is long enough, ENABLE the Textbox's scroll bar TextBox1.Activate ' Set the current select line: 0 TextBox1.CurLine = 0 End Sub
-----------------------Form Textbox--------------------------
Private Sub CommandButton1_Click() TextBox1.Value = "safdasfgsdfgfhfgjhfjfghjfhjfg" _ & Chr(10) _ & "1234567890" _ & Chr(10) ' IF the text length is long enough, ENABLE the Textbox's scroll bar TextBox1.SetFocus ' Set the current select line: 0 TextBox1.SelStart = 0 End Sub
知识点:
ActiveX Textbox中的 TextBox1.Activate 和 Form Textbox的 TextBox1.SetFocus功能相同
相关文章推荐
- powerdesigner vba 创建表和列
- 运行vb写的程序,有些电脑上会弹出一个与office相关的窗口
- VB.net学习笔记(十四) 反射、多态
- 变量、数组、集合、泛型的发展
- VB 6.0 - the first day
- VB 里常用的延时方法
- VB Strings
- VB Structures
- VB|xp风格:终于解决了“图片优化软件”在部分xp系统上无法启动的问题。
- VB: 再次使用的体会
- Vb.net/VB 声明API功能父窗口功能
- 【VB】删除MSHFlexGrid控件中一行(机房问题)
- 【VB】MDI子窗体显示(机房问题)
- 【VB】打开原机房(机房问题)
- 【VB】学生信息管理系统优化总结
- 【VB】学生信息管理系统问题总结
- [OpenGL ES 06]使用VBO:顶点缓存
- vba编程不知道该使用什么对象属性方法实现操作的时候用宏录制来查阅代码
- VB键盘鼠标无动作调用程序的尝试
- VB实现禁用任务管理器的方法