How to use the button event of C #
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!