如何在鼠标单击后删除按钮文本边框 [英] how to remove button text border after clicked by mouse

查看:105
本文介绍了如何在鼠标单击后删除按钮文本边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,我用平面式按钮赢得了胜利。当我点击按钮时,边框会出现在按钮周围。如果我点击一边,它就会消失。当我按空格键时,自动按钮点击事件就会触发。我几乎试过了。但我不能解决这个问题请帮助先生。我的表单控件:一个面板,一个树视图,3个按钮(平面样式)

解决方案

空格键应该调用点击按钮上的事件。这是你不应该避免的预期效果;否则你会混淆你的用户。



当你提出这样的问题时,请指定完整的类型名称。使用类型名称Button,有几种不同的相似类型无关; Panel和许多其他类型也一样。



-SA


我认为你问第一次点击按钮。

稍后当用户点击空格键时,按钮事件再次触发。



是它会发生。当你点击按钮时,焦点将被设置为按钮。因此,当用户按空格键时,按钮点击事件触发。



为了避免这种情况您的按钮单击

首先编写代码,然后根据需要将焦点设置为某些标签,文本框或其他控件,例如,请参阅下面的代码。点击按钮。



  private   void  button1_Click( object  sender,EventArgs e)
{
MessageBox.Show( welcome);
label1.Focus();
}





这里的按钮点击事件我显示消息框并将焦点设置为标签。



如果按空格键,按钮事件将不会消失。

希望你得到你的解决方案:)


Dear Sir, I hav winform with flat style buttons. when i click on buttons,border is apperaing around button.if i click out side, it disappearing.and when i press space bar, automatically button click event is firing. i tried almostly .but i cant solve this pls help Sir. My form controls: "one panel,one treeview, 3 buttons(flat style)"

解决方案

Space bar should invoke the Click event on the button. This is expected effect which you should not avoid; otherwise you would confuse you users.

When you ask such questions, always specify full type name. There are several different unrelated by similar type using the type name "Button"; the same goes for "Panel" and many other types.

—SA


I think you are asking about first time you click the Button .
Later when user click on Space bar the button event is triggering again.

Yes it will happen .When ever you click on Button the focus will be set to button .So when user press Space bar the button click event triggers.

To avoid this in your button click
first write your code and then set focus to some lable ,textbox or other controls as you wish for example see the below code. in button click.

private void button1_Click(object sender, EventArgs e)
      {
          MessageBox.Show("welcome");
          label1.Focus();
      }



here in button click event i display the message box and set the focus to label.

If press space bar the button event will not triger .
Hope you get your solution :)


这篇关于如何在鼠标单击后删除按钮文本边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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