Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the button event of C #

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to use the button event of C#". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

C # button event description: n button on splitContainer1.Panel2

The C # button event requires that when the mouse enters (mouseEnter) any button area, the font of the button turns red and will be restored after mouseLeave. But I don't want to add mouseEnter and leave events one by one for each button. I need to write a method to implement it.

Add the following code to the constructor or Form_Load event

Foreach (Control ctrl in splitContainer1.Panel2.Controls) {if (ctrl is Button) {ctrl.MouseEnter + = new EventHandler (ctrl_MouseEnter); ctrl.MouseLeave + = new EventHandler (ctrl_MouseLeave);}}

C # button event plus the following two methods

Private void ctrl_MouseEnter (object sender, EventArgs e) {((Button) sender). ForeColor = Color.Red;} private void ctrl_MouseLeave (object sender, EventArgs e) {(Button) sender). ForeColor = Color.Black;// change to your default color}

Write a CSS stylesheet. Are you talking about CS or BS? for BS, use input and then judge by type. There can be only one method, but each event must have a SupperButton inheriting Button that implements the mouseEnter and leave events. Use SKIN.

Easyto "BackColor=" # EFEFEF "runat=" server "

Style= "text-align:right;border-bottom: 1px solid # 000000

Border-left: 0px solid yellow

Border-right: 0px solid blue; border-top: 0px solid green; ">

Then all you have to do is add SkinId= "easyto" to the C # button event on your page.

This is the end of the content of "how to use the button event of C#". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report