private void AddButton_Click(object sender, EventArgs e) { if (int.TryParse(AddTextBox.Text, out int value)) { var item = new SortedItem(value, items.Count); items.Add(item); this.panel3.Controls.Add(item.ProgressBar); this.panel3.Controls.Add(item.Label); } AddTextBox.Clear(); }
/// <summary> /// Adds a checkbox with the given text to the checklist /// </summary> /// <param name="text">The text on the checkbox</param> private void AddItem(object text) { string itemText = text.ToString(); // Error validatation. If the default to-do is there still, remove it. If it's empty, return if (string.IsNullOrWhiteSpace(text.ToString())) { return; } else if (CheckListItems.Count == 1 && CheckListList.ElementAt(0).Content.ToString() == DefaultTODO) { CheckListList.RemoveAt(0); } // Make a checkbox for the item and add it. CheckListList.Add(MakeCheckBoxForItem(itemText)); AddTextBox.Clear(); // Save the newly created item. DataDealer.WriteChecklistData(CheckListItems); // Fire the event. ItemAdded?.Invoke(this, itemText); }
private void AddTextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) { AddTextBox.Clear(); }