コード例 #1
0
 //create a form for selected string in item box and display it
 private void BtnOpenList_Click(object sender, EventArgs e)
 {
     if (LbExistingLists.SelectedItem != null)
     {
         CreateToDoListFormFromFile(LbExistingLists.GetItemText(LbExistingLists.SelectedItem));
     }
     else
     {
         MessageBox.Show(
             "You did not select a list to open!",
             "Error",
             MessageBoxButtons.OK,
             MessageBoxIcon.Error);
     }
 }
コード例 #2
0
        //deletes list from item box and deletes file for the list
        private void BtnDeleteList_Click(object sender, EventArgs e)
        {
            string name = LbExistingLists.GetItemText(LbExistingLists.SelectedItem);

            dir = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "ToDoList");
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            fileName = Path.Combine(dir, name + ".json");
            File.Delete(fileName);
            LbExistingLists.Items.Remove(LbExistingLists.SelectedItem);
            UpdateListFile();
        }