Calendar
-
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 .
-
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 .
try using a singleton and then just update the form using methods you call from the first form
-
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 .
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 -
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/2001from a curiosity pov is this similar to a singleton pattern or a modification on it?
-
from a curiosity pov is this similar to a singleton pattern or a modification on it?
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 -
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/2001John 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.
-
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.
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 -
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/2001Different 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?
-
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?
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