BUTTON控件

button控件属性表:

PropertyDescription
AutoEllipsisSpecifies whether to append dots () when the text in the button is too long and can't fit the button.
AutoSizeSpecifies whether the button will automatically resize to fit its content.
FlatStyleDetermines the style of the button. Popup makes the button flat, and when you hover on the button, the button will pop out. Flat makes the button flat and when you move point your mouse inside the button, the background color of the button changes.
EnabledIf set to false, the button cannot be clicked or receive focus.
ImageAn optional image that you can place inside the control.
ImageAlignThe alignment of the image in the button.
TextThe caption inside the button.
VisibleTells whether the button is visible or not.

事件列表:

EventDescription
ClickOccurs when you click the button.
EnterOccurs when the control becomes the
active control of the form.
LeaveOccurs when the control becomes
inactive anymore.
LocationChangedOccurs when the location of the
button is changed.
MouseDownOccurs when the mouse pointer is in the button
and the mouse button is pressed down.
MouseEnterOccurs when the mouse enters the button.
MouseHoverOccurs when the mouse stays stationary
in the button for an amount of time.
MouseUpOccurs when you pressed the button and
you let go of the mouse button.
MouseLeaveOccurs when the mouse pointer
leaves the button.

Click作为button的默认事件。我们也可以为 button添加其它事件。建立一个新的窗体,从工具箱拖拽一个button控件到窗体上,把button的name属性设为buttonsample。接着为窗体添加MouseEnter 和 MouseLeave事件。

打开属性窗口,单击“闪电”标识添加事件,如下图:

Accessing events from the Properties Window

MouseEnter 事件代码:

private void buttonSample_MouseEnter(object sender, EventArgs e)
{
    buttonSample.Text = "Mouse has entered!";
}

MouseLeave事件代码:

private void buttonSample_MouseLeave(object sender, EventArgs e)
{
    btnSample.Text = "Mouse has left!";
}

运行结果截图如下:

Button Control Button Control

转载于:https://www.cnblogs.com/irving314/archive/2011/06/25/buttoncontrol.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值