private void LbxWord_MouseUp(object sender, MouseEventArgs e) { int index = LbxWord.IndexFromPoint(e.Location); try { Ttp.Show(transList[index], LbxWord); if (e.Button == MouseButtons.Right) { if (index >= 0) { LbxWord.SelectedIndex = index; this.CmsWordList.Show(Cursor.Position.X, Cursor.Position.Y); } } } catch { } }
private void LbxWord_MouseDoubleClick(object sender, MouseEventArgs e) { //获取当前鼠标双击选择的项; int index = LbxWord.IndexFromPoint(e.Location); if (index != System.Windows.Forms.ListBox.NoMatches) { FormDialogValue form = new FormDialogValue(); form.returnValue = LbxWord.Items[index].ToString(); form.ShowDialog(); if (AddTrans(form.returnValue) != "") { wordList.RemoveAt(index); wordList.Insert(index, form.returnValue); LbxWord.Items.RemoveAt(index); //先移除当前项的值 LbxWord.Items.Insert(index, form.returnValue); //在当前指定项插入新的值 transList.RemoveAt(index); transList.Insert(index, AddTrans(form.returnValue)); } } }