C#中怎样设置Button控件的按下和弹起事件 [GOOGLE: c# button按下效果] [C# radioButton 變成 Button 型態]
資料來源: https://bbs.csdn.net/topics/280080380
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace radioButton2Button
{
public partial class Form1 : Form
{
//按下状态标识
private bool m_btnState;
public Form1()
{
InitializeComponent();
//将radiobutton设为按钮形式
this.radioButton1.Appearance = System.Windows.Forms.Appearance.Button;
this.radioButton1.Checked = false;
this.m_btnState = this.radioButton1.Checked;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void radioButton1_Click(object sender, EventArgs e)
{
if (m_btnState == false)
{
this.radioButton1.Checked = true;
this.m_btnState = true;
}
else
{
this.radioButton1.Checked =false;
this.m_btnState=false;
}
}
}
}
|