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. Calendar

Calendar

Scheduled Pinned Locked Moved C#
helpquestion
9 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.
  • B Offline
    B Offline
    boiDev
    wrote on last edited by
    #1

    Hi All I have a calendar on one form and a schedule on the other form. I have this code on the calendar new Schedule().Show(); Every time i click on the calendar it opens a dialog box and if i keep clocking it will keep on open more dialogs. I want it so that when i click on a date i will show me on the Schedule. Can anyone help me? Thanks in advance .

    M realJSOPR 2 Replies Last reply
    0
    • B boiDev

      Hi All I have a calendar on one form and a schedule on the other form. I have this code on the calendar new Schedule().Show(); Every time i click on the calendar it opens a dialog box and if i keep clocking it will keep on open more dialogs. I want it so that when i click on a date i will show me on the Schedule. Can anyone help me? Thanks in advance .

      M Offline
      M Offline
      Michael Bookatz
      wrote on last edited by
      #2

      try using a singleton and then just update the form using methods you call from the first form

      1 Reply Last reply
      0
      • B boiDev

        Hi All I have a calendar on one form and a schedule on the other form. I have this code on the calendar new Schedule().Show(); Every time i click on the calendar it opens a dialog box and if i keep clocking it will keep on open more dialogs. I want it so that when i click on a date i will show me on the Schedule. Can anyone help me? Thanks in advance .

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        Well, your design is flawed. You should 0) make the Schedule form global 1) allocate it once in the constructor of the main form (making its default Visible state as false) 2) when you do whatever it is you do to cause the schedule form to be displayed, simply call schedule.Show(). 3) Make the OK button on the schdeule form hide the form instead of closing it.

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        M 1 Reply Last reply
        0
        • realJSOPR realJSOP

          Well, your design is flawed. You should 0) make the Schedule form global 1) allocate it once in the constructor of the main form (making its default Visible state as false) 2) when you do whatever it is you do to cause the schedule form to be displayed, simply call schedule.Show(). 3) Make the OK button on the schdeule form hide the form instead of closing it.

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          M Offline
          M Offline
          Michael Bookatz
          wrote on last edited by
          #4

          from a curiosity pov is this similar to a singleton pattern or a modification on it?

          realJSOPR 1 Reply Last reply
          0
          • M Michael Bookatz

            from a curiosity pov is this similar to a singleton pattern or a modification on it?

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            My approach assumes that the schedule form will always be needed, and makes the allocation attempt only one time. Single allocation results in a performance gain (no overhead for the allocation, and the GC isn't needed), unless the schedule form constructor accepts some sort of parameter from the parent form. At that point, a property or helper function to be called before Show() would still prevent the need to constant reallocate. I wouldn't use a singleton unless the boss told me to, or unless some other reason caused by the requirements or code forced me to do so.

            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

            M 1 Reply Last reply
            0
            • realJSOPR realJSOP

              My approach assumes that the schedule form will always be needed, and makes the allocation attempt only one time. Single allocation results in a performance gain (no overhead for the allocation, and the GC isn't needed), unless the schedule form constructor accepts some sort of parameter from the parent form. At that point, a property or helper function to be called before Show() would still prevent the need to constant reallocate. I wouldn't use a singleton unless the boss told me to, or unless some other reason caused by the requirements or code forced me to do so.

              "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
              -----
              "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

              M Offline
              M Offline
              Michael Bookatz
              wrote on last edited by
              #6

              John Simmons / outlaw programmer wrote:

              I wouldn't use a singleton unless the boss told me to, or unless some other reason caused by the requirements or code forced me to do so.

              Why not? I always thought it to be a useful pattern and seems to do similar to what you are saying. The only difference being that it initialises it on first use rather then at the beginning of the use of the form. Is there a problem with it I should be aware of so I limit using it.

              realJSOPR 1 Reply Last reply
              0
              • M Michael Bookatz

                John Simmons / outlaw programmer wrote:

                I wouldn't use a singleton unless the boss told me to, or unless some other reason caused by the requirements or code forced me to do so.

                Why not? I always thought it to be a useful pattern and seems to do similar to what you are saying. The only difference being that it initialises it on first use rather then at the beginning of the use of the form. Is there a problem with it I should be aware of so I limit using it.

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #7

                hopingToCode wrote:

                Is there a problem with it I should be aware of so I limit using it.

                Not at all. I simply have a different way of doing it. Isn't programming fun? :) BTW, my way of doing it enables me to simply call show when I want to see the dialog. I don't have to try allocating it first.

                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                M 1 Reply Last reply
                0
                • realJSOPR realJSOP

                  hopingToCode wrote:

                  Is there a problem with it I should be aware of so I limit using it.

                  Not at all. I simply have a different way of doing it. Isn't programming fun? :) BTW, my way of doing it enables me to simply call show when I want to see the dialog. I don't have to try allocating it first.

                  "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                  -----
                  "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                  M Offline
                  M Offline
                  Michael Bookatz
                  wrote on last edited by
                  #8

                  Different minds work in different ways and you can learn from all the different ways What do you do about GC? what happens if your form has been GC while hidden or do you just put a check in place first?

                  realJSOPR 1 Reply Last reply
                  0
                  • M Michael Bookatz

                    Different minds work in different ways and you can learn from all the different ways What do you do about GC? what happens if your form has been GC while hidden or do you just put a check in place first?

                    realJSOPR Offline
                    realJSOPR Offline
                    realJSOP
                    wrote on last edited by
                    #9

                    It can't be GC'd until the parent form is disposed (because the schedule form is a member variable of the parent form), so the schedule form is always available once allocated.

                    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                    -----
                    "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                    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