有这样一段程序:procedure Tfrm_cggl_cgjh.DBGridDetailDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState);
begin
  if (gdfocused in state)  then
  begin
    if Column.FieldName = 'xqrq' then   //控制DateTimePicker的位置
      begin
        DateTimePickerXq.Visible:= true;
        DateTimePickerXq.SetBounds(Rect.Left+DBGridDetail.Left+1,
        Rect.Top+DBGridDetail.Top+1, Rect.Right-Rect.Left,Rect.Bottom-Rect.Top);
        if Column.Field.AsString <> '' then
          DateTimePickerXq.Date:= Column.Field.AsDateTime;
      end;
    if Column.FieldName <> 'xqrq' then
      DateTimePickerXq.Visible:= false;
  end;请问其中的if (gdfocused in state) 是什么意思啊?

解决方案 »

  1.   

    当前DBGrid的某单元格处于获得焦点状态。
    程序片断的意思是在自绘DBGrid单元格时,如果当前要绘制的单元格处于焦点激活状态,做以下处理。
      1、列字段名称是 "xqri",则自单元格显示DateTimePickerXq日期控件,日期控件的填充区域和单元格一致。
      2、列字段名称不是 "xqri",则把日期控件隐藏。该功能用DBGridEh控件可以实现,即如果DBGridEh控件绑定的记录集某字段是日期类型,输入时,自动变成DateTimePicker输入方式,不需要自绘控件。
      

  2.   

     TGridDrawState = set of (gdSelected, gdFocused, gdFixed);gdSelected The cell is currently selected.
    gdFocused The cell has input focus.
    gdFixed         The cell is in the fixed region of the grid.