DBGrid1双击后把该条记录的内容写入Memo1中,同时该条记录的颜色想换一下以表明该条记录已选过 
双击多条记录后,双击过的记录都变一下颜色 
能不能实现?

解决方案 »

  1.   

    表中加字段isSel,如果双击后则为true 
    with   (Sender   as   TDBGridEh).Canvas   do
    begin
    if   ADOQuery1.fieldbyname('Xwlx').AsString='通用类询问笔录'   then
    if   ADOQuery1.fieldbyname('isSel').AsBoolean=true   then
    begin
    Brush.Color   :=clSkyBlue;
    FillRect(Rect);
    TextOut(Rect.Left,   Rect.Top,   Column.Field.DisplayText);
    end
    else
    begin
    Brush.Color   :=clBtnFace;
    FillRect(Rect);
    TextOut(Rect.Left,   Rect.Top,   Column.Field.DisplayText);
    end;
    end;
      

  2.   

    procedure TfrmTyxwbl.DBGridEh5DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
    begin
      with (Sender as TDBGridEh).Canvas do
      begin
        if ADOQuery5.FieldByName('IsSel').AsBoolean then
        begin
          Brush.Color:=clSkyBlue;
          FillRect(Rect);
          DBGridEh5.DefaultDrawColumnCell(Rect,DataCol,Column,
          [gdFixed,gdFocused,gdSelected]);
        end
        else
        begin
          Brush.Color:=clBtnFace;
          FillRect(Rect);
          DBGridEh5.DefaultDrawColumnCell(Rect,DataCol,Column,
          [gdFixed,gdFocused,gdSelected]);
        end;
      end;
    end;