VB中textbox里面显示的内容怎么设置成只能复制不能修改

2024-11-17 14:55:19
推荐回答(2个)
回答1:

简单的可以直接 Text.Locked = True,但是不能限制右键的粘贴。
如果要连右键粘贴也限制的可试试这样

Dim Str As String

Private Sub Command1_Click()
Str = "123"
Text.Text = Str
End Sub

Private Sub Form_Load()
Str = "abc"
Text.Text = Str
End Sub

Private Sub Text_Change()
Text.Text = Str
End Sub

回答2:

Dim s As String
Private Sub Form_Load()
s = Text1.Text
End Sub

Private Sub Text1_Change()
Text1.Text = s
Text1.SelStart = Len(Text1.Text)
End Sub