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. Event and EventArg data propagation though nested UserControls

Event and EventArg data propagation though nested UserControls

Scheduled Pinned Locked Moved C#
3 Posts 3 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.
  • H Offline
    H Offline
    hain
    wrote on last edited by
    #1

    I have a DayCell usercontrol class, which has a property Date (of type DateTime). I also have a MonthCal usercontrol which has a collection of DayCells. Finally, I have a YearCal usercontol which has a collection of MonthCals. I would like the YearCal to have a DateChanged event which is fired when a DayCell is clicked. I would like the Date property of the clicked Daycell to be made available to the YearCal client (via an EventArgs-derived parameter). I could create an event in MonthCal that is subscribed to by YearCal, which then fires the DateChanged event. There MUST be a more elegant way for the click event and date information to propagate from DayCell to MonthCal to YearCal, but for the life of me, I can't figure it out. I would be grateful for any suggestions. Thanks, tfhain

    L D 2 Replies Last reply
    0
    • H hain

      I have a DayCell usercontrol class, which has a property Date (of type DateTime). I also have a MonthCal usercontrol which has a collection of DayCells. Finally, I have a YearCal usercontol which has a collection of MonthCals. I would like the YearCal to have a DateChanged event which is fired when a DayCell is clicked. I would like the Date property of the clicked Daycell to be made available to the YearCal client (via an EventArgs-derived parameter). I could create an event in MonthCal that is subscribed to by YearCal, which then fires the DateChanged event. There MUST be a more elegant way for the click event and date information to propagate from DayCell to MonthCal to YearCal, but for the life of me, I can't figure it out. I would be grateful for any suggestions. Thanks, tfhain

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, if your YearCal holds say 12 MonthCals (lets hope it instantiates them by code, not by Visual Designer manipulations), then yes the proper way would be for it to subscribe to each MonthCal's Changed event and act upon it. It seems like you are creating almost 400 controls to represent one year's worth of calendar. That is a lot of stuff, and it is bound to paint rather slow, and react sluggish to all kinds of events (Form minimize/maximize/restore, repaints when uncovered, etc). I would recommend a more lightweight approach using maybe only one Control where you do all the painting explicitly, and the keyboard/mouse interaction by explicit code. It will probably result in less code (more hand-written code though) and far better performance. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


      1 Reply Last reply
      0
      • H hain

        I have a DayCell usercontrol class, which has a property Date (of type DateTime). I also have a MonthCal usercontrol which has a collection of DayCells. Finally, I have a YearCal usercontol which has a collection of MonthCals. I would like the YearCal to have a DateChanged event which is fired when a DayCell is clicked. I would like the Date property of the clicked Daycell to be made available to the YearCal client (via an EventArgs-derived parameter). I could create an event in MonthCal that is subscribed to by YearCal, which then fires the DateChanged event. There MUST be a more elegant way for the click event and date information to propagate from DayCell to MonthCal to YearCal, but for the life of me, I can't figure it out. I would be grateful for any suggestions. Thanks, tfhain

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        In your current set up, that is the correct way IMO.

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
        Why are you using VB6? Do you hate yourself? (Christian Graus)

        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