private void LoginListBox_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int index = this.LoginListBox.IndexFromPoint(e.Location); if (index != ListBox.NoMatches) { String item = LoginListBox.Items[index].ToString(); ContextMenu cm = new ContextMenu(); MenuItem menu1 = new MenuItem(); MenuItem menu2 = new MenuItem(); menu1.Text = "메시지보내기"; menu2.Text = "경로보기"; menu1.Click += (senders, es) => { if (!item.Equals(myname)) { this.Invoke(new Action(delegate() { SendMesage frm = new SendMesage(this, item); frm.Show(); })); } }; menu2.Click += (senders, es) => { MsgSender("PATH#" + item); }; cm.MenuItems.Add(menu1); cm.MenuItems.Add(menu2); cm.Show(LoginListBox, new Point(e.X, e.Y)); } } }
private void LoginListBox_MouseDoubleClick(object sender, MouseEventArgs e) { if (LoginListBox.SelectedItems.Count == 1) { string select = LoginListBox.SelectedItem.ToString(); if (!select.Equals(myname)) { this.Invoke(new Action(delegate() { SendMesage frm = new SendMesage(this, select); frm.Show(); })); } } }