zoukankan      html  css  js  c++  java
  • Excel VBA TextBox控件的滚动条不能刷新

    问题:Excel中Textbox控件以及Form里的Textbox控件,当直接填充的内容很长时,滚动条不能实时刷新。

    现象:

    修改后:

    原因:

    虽然已经向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功能相同

  • 相关阅读:
    欧几里得 与 扩展欧几里得
    hdu-1559 最大子矩阵
    hdu-1081 To The Max (最大子矩阵和)
    Oracle处理排序问题
    报表犯的错误
    MySQL中汉字一二三排序问题
    MySQL复习
    帆软查看显示和填报显示
    MySQL某年查询12个月份的数据
    mysql中去日期格式
  • 原文地址:https://www.cnblogs.com/iluzhiyong/p/4586107.html
Copyright © 2011-2022 走看看