By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,933 Members | 1,574 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,933 IT Pros & Developers. It's quick & easy.

MonthCalendar and DateChanged + DateSelected events

P: n/a
Hi all,

Scenario:

I have a MonthCalendar control, and DataGridView. Depending on dates
displayed in MonthCalendar I want to update information from database.

The Possible Solution:

So I must use DateChanged and/or DateSelected events to get the new dates
and update info from the database. Letís say the implementation is simple:
in these events I call a function passing the SelectionStart and
SelectionEnd which updates the database.

The problem:

Let's say I use DateChanged event. If user uses the navigation buttons and
navigates from one month to other, the DateChanged event is fired two times
(in our scenario - two calls to the database)

If the user decides to select dates with the mouse by simply dragging
through them. Let's say he starts at 05.15 and ends at 05.19 day. DataChange
event is fired 5 times (in our scenario - five calls to the database)

So we are wasting database resources.

If I try to use the DateSelected event, things are better, the event is
fired one time if the date is selected, but event isn't fired at all if user
uses buttons for navigation

Any ideas?

May 4 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"meska" <me***********@fmu1.net> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi all,

Scenario:

I have a MonthCalendar control, and DataGridView. Depending on dates
displayed in MonthCalendar I want to update information from database.

The Possible Solution:

So I must use DateChanged and/or DateSelected events to get the new dates
and update info from the database. Let's say the implementation is simple:
in these events I call a function passing the SelectionStart and
SelectionEnd which updates the database.

The problem:

Let's say I use DateChanged event. If user uses the navigation buttons and
navigates from one month to other, the DateChanged event is fired two
times
(in our scenario - two calls to the database)

If the user decides to select dates with the mouse by simply dragging
through them. Let's say he starts at 05.15 and ends at 05.19 day.
DataChange
event is fired 5 times (in our scenario - five calls to the database)

So we are wasting database resources.

If I try to use the DateSelected event, things are better, the event is
fired one time if the date is selected, but event isn't fired at all if
user
uses buttons for navigation

Any ideas?


It seems to me that what you want is to update the database when the user
FINISHES doing things on the MonthCalendar. Some ideas for this are:
- provide an explicit way for the user to indicate this, e.g. an "Update
Now" button;
- update the databse when the user moves away from the Monthcalendar,
perhaps by handling the Validating event;
- update the database when no changes happen on the MonthCalendar for a few
seconds (start a timer whenever the DateChanged event is fired (first
cancelling the timer if it's already going), then update the database when
the timer expires).

Hope this helps.
Chris Jobson
May 4 '06 #2

P: n/a
"meska" <me***********@fmu1.net> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi all,

Scenario:

I have a MonthCalendar control, and DataGridView. Depending on dates
displayed in MonthCalendar I want to update information from database.

The Possible Solution:

So I must use DateChanged and/or DateSelected events to get the new dates
and update info from the database. Let's say the implementation is simple:
in these events I call a function passing the SelectionStart and
SelectionEnd which updates the database.

The problem:

Let's say I use DateChanged event. If user uses the navigation buttons and
navigates from one month to other, the DateChanged event is fired two
times
(in our scenario - two calls to the database)

If the user decides to select dates with the mouse by simply dragging
through them. Let's say he starts at 05.15 and ends at 05.19 day.
DataChange
event is fired 5 times (in our scenario - five calls to the database)

So we are wasting database resources.

If I try to use the DateSelected event, things are better, the event is
fired one time if the date is selected, but event isn't fired at all if
user
uses buttons for navigation

Any ideas?


It seems to me that what you want is to update the database when the user
FINISHES doing things on the MonthCalendar. Some ideas for this are:
- provide an explicit way for the user to indicate this, e.g. an "Update
Now" button;
- update the databse when the user moves away from the Monthcalendar,
perhaps by handling the Validating event;
- update the database when no changes happen on the MonthCalendar for a few
seconds (start a timer whenever the DateChanged event is fired (first
cancelling the timer if it's already going), then update the database when
the timer expires).

Hope this helps.
Chris Jobson
May 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.