qq_38872713
2018-11-26 09:04c# 中如何封装一个方法?
我想封装一个方法简便一下代码,大概内容是鼠标移动到按钮会在Image中加上图片以,如果按钮是已经点击过的,鼠标移动过去不会发变改mIage状态。
private static bool picregisterFlag;
private static bool picuserAdministrationFlag;
private void pictureBox1_Click_1(object sender, EventArgs e)
{
(** this.tabControl1.SelectedIndex = 0;**
** picregisterFlag=true;**
- picuserAdministrationFlag = false;
** picregister.BackgroundImage = Resources.用户注册选中;**
-
picuserAdministration.BackgroundImage = Resources.用户管理;**)
对这部分进行封装一个方法
}
private void pictureBox2_Click(object sender, EventArgs e)
{
this.tabControl1.SelectedIndex = 1;picregisterFlag = false; picuserAdministrationFlag = true; picregister.BackgroundImage = Resources.用户注册; picuserAdministration.BackgroundImage = Resources.用户管理选中; } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (picregisterFlag == true) { picregister.Image = null; } else { picregister.Image = Resources.导航鼠标经过; } } private void pictureBox2_MouseMove(object sender, MouseEventArgs e) { if (picuserAdministrationFlag == true) { picuserAdministration.Image = null; } else { picuserAdministration.Image = Resources.导航鼠标经过; } }
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- C#创建实体,总是有几个属性报警上下文中找不到
- 开发语言
- 1个回答
- C# WinForm 中鼠标在PictureBox中触发事件会调用构造函数吗?
- c#
- 1个回答
- c#无法使用QtCreator封装的dll,报错误System.BadImageFormatException
- c++
- c#
- visual studio
- 1个回答
- C# 如何把值类型的变量作为引用加入到list中?
- c#
- 2个回答
- c# .net用火狐内核写了一个浏览器。
- 内核
- 浏览器
- 标签
- c#
- 火狐
- 2个回答
换一换