private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e) { if (listBox1.SelectedItem != null && e.Y <= (listBox1.Items.Count * listBox1.ItemHeight)) { ((Form1)this.Owner).TmpGood = ((Good)listBox1.SelectedValue); GoodInfo goodInfo = new GoodInfo(); foreach (KeyValuePair<Button, Good> btnGd in ((Form1)this.Owner).DictButGood) { if (btnGd.Value.GoodID == ((Good)listBox1.SelectedValue).GoodID) { ((Form1)this.Owner).TmpButton = btnGd.Key; break; } } goodInfo.Show(this.Owner); } }
void button_MouseClick(object sender, MouseEventArgs e) { if (!changeStat) { tmpGood = dictButGood[(Button)sender]; tmpButton = (Button)sender; GoodInfo goodInfo = new GoodInfo(); goodInfo.Show(this); } }