Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Problem with TDateEditComboBox
Sun, Nov 18 2018 2:19 PMPermanent Link

ooptimum

The behavior of DateEditComboBox control differs depending on whether it's bound to a dataset or not, also it shows the same date differently depending on that.

I have attached a simple demo project you can play around, to see how event handlers are called and what values the controls have inside, depending on your actions.

For example, do the following:

1. Clear date value in the table (press in a date field: enter, backspace or delete, down, up), so that the bound DateEditComboBox control is also empty;
2. Click on the dataset-bound DateEditComboBox;
3. Type any valid date in edit field, let it be 11/11/11, note that new values in the log are empty while you type;
4. Clear the log, note that the date value in the table is also updated;
5. Click twice on the calendar icon of the dataset-bound DateEditComboBox (just open and close a calendar);
6. Note that date values of bound and unbound editors in the log are same, but differs in the controls and the table;
7. Click on the bound DateEditComboBox and press backspace until edit field is empty, note that its value in the log still remains 11/11/2011;
8. Switch to the unbound DateEditComboBox and select any date in the calendar;
9. Switch back to the bound DateEditComboBox and try to edit in manually. You can't do it anymore. Almost whatever key you would press from now on will just decrement date in the editor.

How to make the behavior of an unbound control identical to the bound one, and why they differ?



Attachments: demo.zip
Mon, Nov 19 2018 6:28 AMPermanent Link

Walter Matte

Tactical Business Corporation

Your probably in some loop here.

You have OnChange of Date1 changing Date2 and OnChange of Date2 changing Date1.

If values are not what you expect the issue is probably Localization.

Without the loop of onchange altering the other date control - demonstrate bounded and unbounded individually and tell us what you think is wrong.  

I have never seen an issue and I have done quite a few Timesheet systems using EWB that use both bounded and unbounded data controls.

Walter
Mon, Nov 19 2018 7:10 AMPermanent Link

Walter Matte

Tactical Business Corporation

This example will demonstrate localization issue:


 DateEditComboBox2.SelectedDate := DataSet1.Columns['Date'].AsDate;


 DateEditComboBox2.SelectedDate := DataSet1.Columns['Date'].AsDate +  
TimeZoneOffSet(DataSet1.Columns['Date'].AsDate) * 60 * 1000);


Attached:

Run - change Bounded Date Control - click Navigaotr to SAVE to Dataset.
Click A to B - this updates the unbounded control - it was not the date I expected.
Click A to B FIX - this updates the unbounded control with the date I expect.

Walter



Attachments: demodate.zip
Mon, Nov 19 2018 8:23 AMPermanent Link

Walter Matte

Tactical Business Corporation

You can also set TDataSet LocalizeDateTimeCoumns to TRUE and not use the A B Fix.

Walter
Image