Properties 里,Date:2022-03-05 Format:YYYY/MM/DD 一、 VAR aF:TFormatSettings; begin aF:=TFormatSettings.Create('zh-CN'); aF.ShortDateFormat:='yyyy-mm-dd'; aF.DateSeparator:='-'; DateEdit1.Date:=strtodate('2022-03-03',af);
结果:闪退
二、 Properties 里,Date:2022-03-05 Format:YYYY/MM/DD
VAR aF:TFormatSettings; begin aF:=TFormatSettings.Create('zh-CN'); aF.ShortDateFormat:='yyyy/mm/dd'; aF.DateSeparator:='/'; DateEdit1.Date:=strtodate('2022-03-03',aF);
结果:‘2022-03-03’ is not a valid date
三、 Properties 里,Date:2022-03-05 Format:YYYY/MM/DD VAR aF:TFormatSettings; begin aF:=TFormatSettings.Create('zh-CN'); aF.ShortDateFormat:='yyyy/mm/dd'; aF.DateSeparator:='/'; DateEdit1.Date:=strtodate('2022/03/03',aF);
结果:闪退
四、Properties 里的 Format:(为空) VAR aF:TFormatSettings; begin aF:=TFormatSettings.Create('zh-CN'); aF.ShortDateFormat:='yyyy/mm/dd'; aF.DateSeparator:='/'; DateEdit1.Date:=strtodate('2022/03/03',aF);
结果:闪退
五、Properties 里的 Format:(为空) VAR aF:TFormatSettings; begin aF:=TFormatSettings.Create('zh-CN'); aF.ShortDateFormat:='yyyy-mm-dd'; aF.DateSeparator:='-'; DateEdit1.Date:=strtodate('2022-03-03',aF);
结果:闪退
六、Properties 里的 Format:yyyy-mm-dd VAR aF:TFormatSettings; begin aF:=TFormatSettings.Create('zh-CN'); aF.ShortDateFormat:='yyyy-mm-dd'; aF.DateSeparator:='-'; DateEdit1.Date:=strtodate('2022-03-03',aF);