vb.net VB 按下按钮后禁用文本框。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26247914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VB Disabling textboxes after button is pressed.
提问by R4g323
is there a way to disable a textbox in code only when an even is triggered? for example, a textbox wants user to enter an initial amount of money in a textbox. After the calculate button is clicked, make the textbox not editable. im a beginner and my textbook doesnt mention it.
有没有办法仅在触发偶数时禁用代码中的文本框?例如,文本框希望用户在文本框中输入初始金额。单击计算按钮后,使文本框不可编辑。我是初学者,我的教科书没有提到它。
回答by
To disable
textboxon button clickPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Enabled = False End SubTo make it Read Only
TextBox1.ReadOnly = TrueThe difference between
EnabledandReadOnlyis :
要禁用
textbox按钮单击Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Enabled = False End Sub使其只读
TextBox1.ReadOnly = True之间的区别
Enabled和ReadOnly是:
Readonlyallows the user to set focus to and select and copy the text but not modify it. A disabledTextBox does not allow any interaction whatsoever.
Readonly允许用户设置焦点并选择和复制文本,但不能修改它。一个禁用的文本框不允许任何交互任何责任。
Use ReadOnlywhen you have data that you want the user to see and copy, but not modify. Use a disabled textbox, when the data you are displaying is not applicablein for the current state of a dialog or window.
当您希望用户查看和复制但不修改数据时,请使用ReadOnly。当您显示的数据不适用于对话框或窗口的当前状态时,请使用禁用的文本框。

