简体   繁体   中英

I can not go to "EventHandler" with double click

When btnAsset is double-clicked, it should go to allButton_Click . But it only goes in one click. how can I do that?

public void Add(MainForm frm)
{
    this.form1 = frm;
        for (int i = 0; i < 10; i++)
        {
            btnAsset[i] = new Button();
            btnAsset[i].Tag = i;
            btnAsset[i].Name = "Asset-" + i.ToString();
            btnAsset[i].Width = 150;
            btnAsset[i].Height = 120;
            btnAsset[i].Visible = true;
            btnAsset[i].BackColor = Color.GreenYellow;

            form1.flowLayoutVideo.Controls.Add(btnAsset[i]);

           btnAsset[i].DoubleClick += new EventHandler(allButton_Click);
        }
  }

should go here when double clicked

void allButton_Click(object sender, EventArgs e)
{
    Button p = sender as Button;
    if (p != null)
    {
        int i = (int)p.Tag;
        MessageBox.Show((i + 1).ToString() + ". seçildi");
    }
}

Look what the docs says about it:

By default, the ControlStyles.StandardClick and ControlStyles.StandardDoubleClick style bits are set to false for the Button control, and the DoubleClick event is not raised.

You can change this behaviour by creating your own button class deriving from Button and change the style bits.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM