且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何锁定vb.net中的按钮

更新时间:2023-12-06 12:19:52

如果按钮被锁定,您可以只吃事件.但是,禁用按钮是您现在不能使用此控件"的标准惯用方式.

如果您不喜欢显示为灰色的外观,则可以始终将它们完全隐藏起来,但是根据多年设计用户界面的经验,我可以告诉您,当内容从屏幕上消失后,用户并不喜欢它.屏幕.
You could just eat the event if the button is locked. However, making the button disabled is the standard indisutry way of saying "you can''t use this control right now".

If you don''t like the grayed-out appearance, you could always completely hide them, but I can tell you from a number of years of experience designing user interfaces that users don''t really like it when stuff just disappears from the screen.


我曾经让客户抱怨说,当文本框被禁用甚至是只读时,他们无法读取其中的值.为了解决诸如此类的问题,我有一个变量来跟踪何时应该将其视为只读.然后,当该变量设置为true时,将跳过这些控件的每个事件.因此,如下所示:

I''ve had customers complain that when textboxes are disabled or even just readonly they can''t read the value in them. To get around things like that I have a variable that tracks when things are supposed to be read-only. Then every event for those controls just gets skipped when that variable is set to true. So, something like this:

Dim boolMakeReadOnly as Boolean = True

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If boolMakeReadOnly Then Return ''This exits the event

''Original code for the submit button (gets skipped if boolMakeReadOnly is true)

End Sub


我不知道这是否可行,请试一试


I don''t know if this is possible, give it a shot


<br />
btnSubmit_CrtIss.Readonly= False<br />
btnReset_CrtIss.Readonly= False