如题。在dbgrid中某一列中,输入日期,我不想用edit,怎么判断日期为有效
?也不想在数据提交是判断,如果解决这个问题,照样给分!!!
救救我!

解决方案 »

  1.   

    在dbgrid中放一个datetimepicker
    1. 放置一个datetimepicker1控件,填写您要选用的值列表,设为Visible:=False
    2.DBGrid1.OnEnter事件里,XXXX为字段名(也可以用selectindex来判断是第几列)
      if (gdFocused in State) and
        (Column.Field = XXXX) then
      begin
        datetimepicker1.DBGrid1DrawColumnCell(
          Rect.Left + DBGrid1.Left + 1,
          Rect.Top + DBGrid1.Top + 1,
          Rect.Right - Rect.Left,
          Rect.Bottom - Rect.Top);
      end;3.DBGrid的ColEnter 事件
      if DBGrid1.Columns [DBGrid1.SelectedIndex].
          Field = XXXX then
        datetimepicker1.Visible := True
      else
        datetimepicker1.Visible := False;
      

  2.   

    同意 rikky(读书、心知、生活)
      

  3.   

    其实,我从来没有用过上面的代码,我已经好久没有用delphi了,不过我也是从上面的代码得到启示自己写了一段,在c++builder里面用,这个就一直保存着, 赫赫,知道怎么做就行了