I am new to c# and am having issues with the syntax and passing an object. I am building a form with a treeview of stores and a list view of customers for each store. When I click a button on the form, 'OnStoreAdd' is called and creates the store object. How do I pass that object to 'AddStoreNode(object?tag?)'?
namespace CustomerInfoObjects { public class Store { private List<Customer> _customers = new List<Customer>(); public List<Customer> Customers { get { return _customers; } set { _customers = value; } } private string _name = string.Empty; public string Name { get { return _name; } set { _name = value; } } } } namespace DomainObjects { public class CustomerList : List<Customer> { } public class StoreToCustomerListDictionary : Dictionary<Store, CustomerList> { } public class CustomerInfoDocument { private StoreToCustomerListDictionary _storeToCustomerList = new StoreToCustomerListDictionary(); public StoreToCustomerListDictionary StoreToCustomerList { get { return _storeToCustomerList; } set { _storeToCustomerList = value; } } } } namespace BusinessLayer { public static class CustomerMgr { private static CustomerInfoDocument _document = new CustomerInfoDocument(); public static bool AddStore(string storeName) { Store store = new Store(); store.Name = storeName; _document.StoreToCustomerList.Add(store, null); return true; } } } namespace UILayer { public partial class StoreTreeControl : UserControl { public StoreTreeControl() { InitializeComponent(); } public void AddStoreNode(Store object? ) //What type of argument? { TreeNode node = _tvwStores.Nodes.Add(store.Name); node.Tag = store; _tvwStores.SelectedNode = node; } private void OnStoreAdd(object sender, System.EventArgs e) { StorePropertiesForm f = new StorePropertiesForm(); if (f.ShowDialog() != DialogResult.OK) return; if (!CustomerMgr.AddStore(f.StoreName)) { MessageBox.Show("Store name should no be blank"); return; } AddStoreNode(?); //What argument would I use here? } } } I don't know how to pass the new store object into the AddStoreNode method. The tag in AddStoreNode method is so that my listview can access treeview nodes. Do I need another tag in the StoreAdd method to use?
Any information that could point me in the right great direction would be greatly appreciated!