示例#1
0
        private void TsmAddWord_Click(object sender, EventArgs e)
        {
            int index = LbxWord.SelectedIndex;

            if (index != System.Windows.Forms.ListBox.NoMatches)
            {
                FormDialogValue form = new FormDialogValue();
                form.returnValue = LbxWord.Items[index].ToString();
                form.ShowDialog();
                if (!wordList.Contains(form.returnValue))
                {
                    if (AddTrans(form.returnValue) != "")
                    {
                        wordList.Insert(index, form.returnValue);
                        LbxWord.Items.Insert(index, form.returnValue);//在当前指定项插入新的值
                        transList.Insert(index, AddTrans(form.returnValue));
                    }
                }
            }
        }
示例#2
0
        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));
                }
            }
        }