111,130
社区成员
发帖
与我相关
我的任务
分享
public Form1()
{
InitializeComponent();
BindEventHandler(this);
//...........
}
private void BindEventHandler(Control ctrl)
{
foreach (Control c in ctrl.Controls)
{
if (c is TextBox)
{
c.MouseDown += new MouseEventHandler(textBox_MouseDown);
}
else
{
BindEventHandler(c);
}
}
}
private void textBox_MouseDown(object sender, MouseEventArgs e)
{
(sender as TextBox).Text = DateTime.Now.ToString();
}
private void groupBox1_MouseCaptureChanged(object sender, EventArgs e)
{
MessageBox.Show("");//or do something else
}