Accessing parts of identical use controls
-
I have a TabControl, and tabs can be dynamically added for users. When a tab is added, a user-control is added to that tab. So each tab has an identical user control, and each control is made up of a group of identical controls. I need to access those controls, in this case, a timer from the main window, but I cannot just use the name of the timer "refreshTimer". How would I access them? I have tried
tabcontrolname.tabpages[selectedIndex].usercontrolname.refreshTimer.Start();
along with several other variations, but none of them have worked so far. Any suggestions? -
I have a TabControl, and tabs can be dynamically added for users. When a tab is added, a user-control is added to that tab. So each tab has an identical user control, and each control is made up of a group of identical controls. I need to access those controls, in this case, a timer from the main window, but I cannot just use the name of the timer "refreshTimer". How would I access them? I have tried
tabcontrolname.tabpages[selectedIndex].usercontrolname.refreshTimer.Start();
along with several other variations, but none of them have worked so far. Any suggestions? -
Every time a new control is added, store it in a ArrayList then you can cast any object from the array list and access its properties.
Either I don't understand your solution or I didn't explain myself very well. It works like this. on my form (MainWindow) I have a TabControl called MonitorTabs. I programmatically add a tab to it for each user I want to monitor like so:
TabTitle = FirstName + " " + LastName; TabPage newMonitorTab = new TabPage(TabTitle); MonitorTabs.TabPages.Add(newMonitorTab);
Then I add a user control called Monitor that contains a group of controls including a timer (RefreshTimer) to that tab like so:Monitor monitor = new Monitor(); monitor.Size = newMonitorTab.Size; monitor.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; monitor.UserID = UserID; newMonitorTab.Controls.Add(monitor);
Then the function ends and other things happen. From the menu in MainWindow, I call a function that needs to reset the interval on RefreshTimer on the currently selected tab. There may be three RefreshTimers, one on each User Control/Tab, and I don't know how to access any of them let alone the one that is currently selected. The timer is set to public, and still nothing shows up. I hope this explains it better. Thanks for any forthcoming help