如何锁定vb.net中的按钮 [英] How to lock button in vb.net

查看:281
本文介绍了如何锁定vb.net中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将表单中的按钮锁定,我尝试了以下

Hi , I am trying to lock a button in my form , i have tried with the following

btnSubmit_CrtIss.Enabled = False
btnReset_CrtIss.Enabled = False


但是它看起来很糟糕,就像一个灰色的文本框一样,我的目标是防止用户单击这些按钮.
请帮助


but it looks awful, just like a greyed out text box, my goal is to prevent users from clicking those buttons.
Please help

推荐答案

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

如果您不喜欢显示为灰色的外观,则可以始终将它们完全隐藏起来,但是根据多年设计用户界面的经验,我可以告诉您,当内容从屏幕上消失后,用户并不喜欢它.屏幕.
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


这篇关于如何锁定vb.net中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆