在窗体中的DBGrid中有固定条数的记录,
我想在选中第一条记录的时候,DBGrid是整行被选中的,
即相当于DBGrid中Options中的dgRowSelect为True。
而在选中其他记录的时候,则只能选中某列的值,
相当于DBGrid中Options中的dgRowSelect为False。

解决方案 »

  1.   

    不知道能不能在OnCellClick中实现
      

  2.   

    //下面是Delphi的例子
    procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);begin
      if Table1.FieldByName('Size').AsFloat > 10 then
        DBGrid1.Canvas.Font.Color := clRed;
      DBGrid1.DefaultDrawDataCell(Rect, Field, State);
    end;你只需要把Table1.FieldByName('Size').AsFloat > 10 改成Table1.RecNo = 1
    DBGrid1.Canvas.TBrush.Color := clRed;
      

  3.   

    在tdataset中控制,在BeforeEdit中写 if Query1.Recno =1 then abort;
      

  4.   

    没问题:follow me@
    在afterscroll:
    if adoquery1.recno=1 then 
    设置DBGrid中Options中的dgRowSelect为True
    else
    设置DBGrid中Options中的dgRowSelect为false
      

  5.   

    我也清楚
    可是如何设置DBGrid中Options中的dgRowSelect为True或False呢?