Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Accessing parts of identical use controls

Accessing parts of identical use controls

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mikan23
    wrote on last edited by
    #1

    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?

    R 1 Reply Last reply
    0
    • M Mikan23

      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?

      R Offline
      R Offline
      rudy net
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • R rudy net

        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.

        M Offline
        M Offline
        Mikan23
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups