TDateTimePicker or TRzDateTimePicker date not changing
来源:互联网 发布:mac内胆包 编辑:程序博客网 时间:2024/06/07 09:32
在使用TRzDateTimePicker的时候。手动设置TRzDateTimePicker的时间后,要么只能设置日期,要么只能设置时间,这个根据该控件的kind属性决定的,且该属性只有dtkTime 和dtkDate两种情况。我们既不想放2个这样的控件,又想同时修改date和time。那么需要做如下处理:
this problem can be solved by reading the Text property, but in delphi this property is protected. so...
TDTPicker = class(TControl)publicproperty Text;end;
in DTPicker onChange read the text and convert to DateTime property
DT1.DateTime := StrToDateTime(TDTPicker(DT1).Text);
上面的DT1是你的TDateTimePicker or TRzDateTimePicker。
说明:StrToDateTime 和电脑的本地时间格式有关系,如果设定的格式和电脑的格式不一致就会报错。
我们可以这么做:
var FSetting : TFormatSettings; DateTime1: tDateTime;begin FSetting := TFormatSettings.Create(LOCALE_USER_DEFAULT); try FSetting.ShortDateFormat:='yyyy-MM-dd'; FSetting.DateSeparator:='-'; FSetting.TimeSeparator:=':'; FSetting.LongTimeFormat:='hh:mm:ss'; DT1.DateTime := StrToDateTime(TDTPicker(DT1).Text,FSetting); finally freeandnil(FSetting); end;end;
也可以这么做:
var formatsetting:TFormatSettings;begin GetLocaleFormatSettings(GetUserDefaultLCID,formatsetting); formatsetting.DateSeparator:='-'; formatsetting.TimeSeparator:=':'; formatsetting.ShortDateFormat:='yyyy-MM-dd'; formatsetting.ShortTimeFormat:='HH:mm:ss'; dtp1.DateTime := StrToDateTime(TDTPicker(dtp1).Text,formatsetting);end;
参考:https://forums.embarcadero.com/message.jspa?messageID=354510
- TDateTimePicker or TRzDateTimePicker date not changing
- One or more files are out of date or do not exist
- dynamically changing delay in gr_delay (or history in any gr_block)
- Changing Interconnect/Public Interface, IP or Subnet in Oracle Clusterware
- Changing or keeping a UUID for a moved virtual machine
- Changing the hostname or computer name in ubuntu
- Dynamically changing the linearlayout width or height on Android
- TDateTimePicker的重绘
- How to change SYSDATE's value to a static date without changing system date
- DATE NOT FOUND
- Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix.
- Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix
- Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix
- Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix
- Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix
- Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix
- Java Date decrease or increase
- VC 6.0 写完的程序程编译链接通过后,点运行的时候出现one or more files out of date or not exist
- 一些面试题
- 网站建设
- Collections.unmodifiableList方法的使用与场景
- java poi word
- Android异步下载图片并且缓存图片到本地
- TDateTimePicker or TRzDateTimePicker date not changing
- c#中通过设置钩子监视鼠标移动
- 19.定义Fibonacci数列,输入n,用最快的方法求该数列的第n项
- 微软面试题 经典测试 (第二组)
- OpenSSL常用命令
- 以HttpGet方法获取URL数据并转换成指定编码格式的字符串
- 命令模式(Command Pattern)
- FlashBulider开发中的ASDOC的使用。
- JAVA链接sql server数据库的步骤(包括tomcat下配置数据源)