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

解决方案 »

  1.   

    可以的吧~~自已改一下dbgrid试试
      

  2.   

    我是在delphi2007中,控件是DBGridEh,有没有代码,能详细一点吗?急用呀,或者是三方控件?
      

  3.   

    在数据库中扩展字段记录是否修改,然后在
    http://www.delphibbs.com/keylife/iblog_show.asp?xid=27763
    然后
    在 DBGrid.OnDrawColumnCell(...) 中:begin
     if TableField.AsInteger < 0 then
       DBGrid.Canvas.Font.Color := clRed
     else
       DBGrid.Canvas.Font.Color := clBlack;
     DBGrid.DefaultDrawColumnCell(...);
    end;
      

  4.   

    不行呀
    DBGrid1双击后把该条记录的内容写入Memo1中,同时该条记录的颜色想换一下以表明该条记录已选过 
      

  5.   

    表中加字段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;
      

  6.   

      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;
      

  7.   

    那你还不如在GRIDE中加CHECKBOX 这样不更好看一些?
      

  8.   

    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;