自動(dòng)選擇Text的內(nèi)容

字號(hào):

在使用 VFP 的應(yīng)用進(jìn)行錄入時(shí),每進(jìn)入一個(gè)錄入框,就自動(dòng)選擇該框中的所有內(nèi)容。利用以下的代碼,也可實(shí)現(xiàn)類似的功能。
    Private Sub MyTextBox_GotFocus()
    AutoSelect MyTextBox
    End Sub
    Sub AutoSelect(SelObject As Control)
    SelObject.SelStart = 0
    If TypeOf SelObject Is MaskEdBox Then
    SelObject.SelLength = Len(SelObject.FormattedText)
    Else
    If TypeOf SelObject Is TextBox Then
    SelObject.SelLength = Len(SelObject.Text)
    End If
    End If
    End Sub