/// <summary> /// method returns the Save /// </summary> public bool OnSave(bool close) { // initial value bool saved = false; // if the value for HasParentListEditorHost is true if (HasParentListEditorHost) { // Save the current edit saved = ParentListEditorHost.Save(); // if saved if (saved) { // Load and display the list LoadAndDisplayList(SelectedItem); } } // Enable or disable controls UIEnable(); // return value return(saved); }
/// <summary> /// event is fired when the 'AddButton' is clicked. /// </summary> private void AddButton_Click(object sender, EventArgs e) { // if the value for HasParentListEditorHost is true if (HasParentListEditorHost) { // Add a new item ParentListEditorHost.Add(); } }
/// <summary> /// event is fired when the 'EditButton' is clicked. /// </summary> private void EditButton_Click(object sender, EventArgs e) { // if the value for HasParentListEditorHost is true if (HasParentListEditorHost) { // Edit the selected item ParentListEditorHost.Edit(); } }
/// <summary> /// event is fired when the 'DeleteButton' is clicked. /// </summary> private void DeleteButton_Click(object sender, EventArgs e) { // if the value for HasParentListEditorHost is true if (HasParentListEditorHost) { // Delete the selected item ParentListEditorHost.Delete(); } // Enable controls UIEnable(); }
/// <summary> /// This method Clear /// </summary> public void Clear() { // remove all items ListBox.Items.Clear(); // clear everything List = null; // if the ListEditorHost exists if (HasParentListEditorHost) { // Clear the control ParentListEditorHost.Clear(); } }
/// <summary> /// This method Load And Display List /// </summary> public void LoadAndDisplayList(object itemToSelect = null) { // get the name of this item string name = ""; // if the itemToSelect exists if (NullHelper.Exists(itemToSelect)) { // set the name name = itemToSelect.ToString(); } // Clear Clear(); // local int index = -1; // if the ParentListEditorHost exists if (HasParentListEditorHost) { // load the list of items List = ParentListEditorHost.LoadList(); // Display the List DisplayList(); } // If the name string exists if (TextHelper.Exists(name)) { // find the index index = FindItemIndex(name); // Set the SelectedIndex ListBox.SelectedIndex = index; // if the SelectedIndex was found if (ListBox.SelectedIndex >= 0) { // Set Focus to the ListBox so the selected item highlights (trying) ListBox.Focus(); } } }
/// <summary> /// method On Cancel /// </summary> public void OnCancel() { // local bool clearRequired = (EditMode == EditModeEnum.Add); // if the value for HasParentListEditorHost is true if (HasParentListEditorHost) { // Cancel the current edit ParentListEditorHost.Cancel(); // if the value for clearRequired is true if (clearRequired) { // Set to -1 ListBox.SelectedIndex = -1; } // Enable or disable controls UIEnable(); } }
/// <summary> /// event is fired when a selection is made in the 'ListBox_'. /// </summary> private void ListBox_SelectedIndexChanged(object sender, EventArgs e) { // if the SelectedItem exists if (ListBox.SelectedItem != null) { // get the text of the SelectedItem from the listbox string itemName = ListBox.SelectedItem.ToString(); // Get the SelectedItem object selectedItem = FindSelectedItem(itemName); // if the value for HasParentListEditorHost is true if ((HasParentListEditorHost) && (NullHelper.Exists(selectedItem))) { // An item was selected in the list ParentListEditorHost.ItemSelected(selectedItem); } // Enable or disable controls UIEnable(); } }