VC ++ 2010 - 如果单击button1

时间:2013-12-17 20:37:49

标签: visual-studio-2010 visual-c++ c++-cli

我的脚本有点问题。我想检查button1是否在另一个事件中被点击(pictureBox_Click)。我怎么能这样做?

应该是这样的:

private: System::Void pictureBox_Click(System::Object^  sender, System::EventArgs^  e) {

if (button1 is clicked=true)
{
  code;
  code;
  code;
}

if (button2 is clicked=true)
{
  code;
  code;
  code;
}

}

我将不胜感激。

1 个答案:

答案 0 :(得分:1)

在变量中单击按钮时需要存储。为按钮单击事件添加事件处理程序,并存储值。

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
{
    buttonClicked = true;
}
private: System::Void pictureBox_Click(System::Object^  sender, System::EventArgs^  e)
{
     if (buttonClicked)
     {
         // ... 
相关问题