DateTimePicker_rkrq的format 是 yyyy-MM-dd hh:mm:ss但我的时间只能为12:00:00,不可以更改,为什么呀?

解决方案 »

  1.   

    这个控件的一个属性是time你可以修改这个属性实现
      

  2.   

    我是在控件上修改,我的控件上显示的是 2003-02-03 12:00:00
    我没有办法把他改成 2003-02-03 13:02:02
    日期是可以改的,时间只能为12:00:00,改不了,改了他自动变成12:00:00我知道有time属性,但我是在控件上改呀
      

  3.   

    要两个一起用,一个DATE,一个TIME
      

  4.   

    DateTimePicker1.DateFormat:=dfLong;
      DateTimePicker1.Format := 'yyyy-mm-dd hh-mm-ss';
      DateTimePicker1.DateTime := now;
      就可以了。
      

  5.   

    我有个方法不过不太好,需要修改delphi的包含Tdatatimepicker的单元ComCtrls.pasprocedure TDateTimePicker.CNNotify(var Message: TWMNotify);
    var
      DT: TDateTime;
      AllowChange: Boolean;
    begin
      with Message, NMHdr^ do
      begin
        Result := 0;
        case code of
          DTN_CLOSEUP:
            begin
              FDroppedDown := False;
              SetDate(SystemTimeToDateTime(FLastChange));
              if Assigned(FOnCloseUp) then FOnCloseUp(Self);
            end;
          DTN_DATETIMECHANGE:
            begin
              with PNMDateTimeChange(NMHdr)^ do
              begin
                if FDroppedDown and (dwFlags = GDT_VALID) then
                begin
                  FLastChange := st;
                  FDateTime := SystemTimeToDateTime(FLastChange);
                end
                else begin
                  if FShowCheckbox and IsBlankSysTime(st) then
                    FChecked := False
                  else if dwFlags = GDT_VALID then
                  begin
                    FLastChange := st;
                    DT := SystemTimeToDateTime(st);
                 // if Kind = dtkDate then SetDate(DT)
                 //   else SetTime(DT);
                 
    //以上原代码注释掉
    //My change
                    SetDate(DT);
                    SetTime(DT);//以上2行我更改
                    if FShowCheckbox then FChecked := True;
                  end;
                end;
                Change;
              end;
            end;
          DTN_DROPDOWN:
            begin
              DateTimeToSystemTime(Date, FLastChange);
              FDroppedDown := True;
              if Assigned(FOnDropDown) then FOnDropDown(Self);
            end;
          DTN_USERSTRING:
            begin
              with PNMDateTimeString(NMHdr)^ do
              begin
                DT := StrToDateTime(pszUserString);
                if Assigned(FOnUserInput) then
                begin
                  AllowChange := True;
                  FOnUserInput(Self, pszUserString, DT, AllowChange);
                  dwFlags := Ord(not AllowChange);
                end
                else
                  dwFlags := Ord(False);
                DateTimeToSystemTime(DT, st);
              end;
            end;
        else
          inherited;
        end;
      end;
    end;
      

  6.   

    对了还有以下需要设置
    TDateTimePicker的
    kind属性改为 dtkTime
    format属性改为 yyyy-MM-dd HH:mm:ss
      

  7.   

    回复人: YANGYUGW(小杨) ( ) 信誉:97  2004-08-21 15:56:00  得分: 0  
     
     
       对了还有以下需要设置
    TDateTimePicker的
    kind属性改为 dtkTime
    format属性改为 yyyy-MM-dd HH:mm:ss
      
     
    这样也不行啦,这样虽然时间可以改,但控件的DATEMODE不起做用了,我希望是combobox的方式来选择时间
      

  8.   

    上面写错了YANGYUGW(小杨)的建议
    这样虽然时间可以改,但控件的DATEMODE不起做用了,我希望是combobox的方式来选择日期按YANGYUGW(小杨)的方法,日期没办法用combobox方式了
      

  9.   

    zcfzcf001(zcf) 要多少分?开个价吧
      

  10.   

    没错,我说的方法是不可以用combobox方法了。
      

  11.   

    我就是需要combobox呀,帮我想下其它办法吧