-
Problem in swap DateTimePicker values
Hi, I have two DateTimePickers to determine date range, with their names are dtStartDate and dtEndDate.
I want to swap their values if dtStartDate value > dtEndDate.
In dtStartDate_ValueChanged event, I only write codes as follows:
Code:
if (dtStartDate.Value > dtEndDate.Value)
{
DateTimePicker dtTemp = new DateTimePicker();
dtTemp.Value = dtStartDate.Value;
dtStartDate.Value = dtEndDate.Value;
dtEndDate.Value = dtTemp.Value;
}
When I ran the code, I got both values are equal (dtStartDate value = dtEndDate).
Step by step debugging showed their values were swapped.
But when the debug step exit from dtStartDate_ValueChanged event, both values became equal.
I guess it happened because of the value passed as reference, not as value.
How to fix it, so I can swap both values?
Thanks for your help / direction.
-
You can use dtStartDate_CloseUp;
after performance dtStartDate.Value = dtEndDate.Value;
another dtStartDate_ValueChanged occurs
Similar Threads
-
By Luis Afonso in forum Database
Replies: 2
Last Post: 04-11-2001, 05:20 AM
-
By IvyS in forum Database
Replies: 0
Last Post: 02-14-2001, 04:16 PM
-
By tyris in forum VB Classic
Replies: 6
Last Post: 02-01-2001, 03:08 AM
-
By tyris in forum Database
Replies: 2
Last Post: 01-24-2001, 02:45 PM
-
By Andreas Roth in forum VB Classic
Replies: 0
Last Post: 04-10-2000, 09:43 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|