示例#1
0
        private void NoteTitleTB_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (!string.IsNullOrEmpty(NoteTitleTB.Text) && !string.IsNullOrWhiteSpace(NoteTitleTB.Text))
                {
                    if (NoteTitleTB.Text != Current_Note.Name)
                    {
                        if (!Duplicate_Note(NoteTitleTB.Text))
                        {
                            NotesLV.Sorting = SortOrder.None;

                            Note_Changes.Remove(Current_Note.Name);
                            Note_Changes.Add(NoteTitleTB.Text, NoteBodyTB.Text);

                            Current_Note.Name = NoteTitleTB.Text;
                            Current_Note.Text = NoteTitleTB.Text;

                            NotesLV.Sorting = SortOrder.Ascending;
                            NotesLV.Sort();
                        }

                        else
                        {
                            MessageBox.Show("Duplicate note titles are not allowed.", "Duplicate Note Title", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            NoteTitleTB.Text = Current_Note.Name;
                            NoteTitleTB.Focus();
                            NoteTitleTB.SelectAll();
                        }
                    }
                }

                e.SuppressKeyPress = true;
            }
        }
示例#2
0
 private void NoteTitleTB_Click(object sender, EventArgs e)
 {
     NoteTitleTB.SelectAll();
 }