各位高手:
    我想要实现这样的功能:在DBGridEh 中有多列BoxCheckButton,但对每一行记录选择时只能选中一列,也就是说我选中其中一列时其他列要显示成未选中,也就是RadioGroup中单选的功能。谢谢指教!!!
    问题已解决立即送分!!!

解决方案 »

  1.   

    关注期望有高手详细指点一下dbgrideh用法
      

  2.   

    Procedure DBGridEhCheckButtion(Sender:TObject;ACol: integer;Cloum:TCloum;var Enabled: Boolean)
    var
      I: integer;
    begin
      for i:= 0 to DBGridEh.FieldsCount-1 do
      begin
        if DBGridEh.FieldCloum[i].Field.DataType=ftBoolean then
        begin
          if DBGridEh.FieldCloum[i].FieldName <> Cloum.FieldName then
          begin
            if DBGridEh.Dataset.State in ([dsInsert,dsEdit]) then
              DBGridEh.Dataset.FieldByName(DBGridEh.FieldCloum[i].FieldName).asBoolean := False;
          end;
        end;  
    end;
    沒有調試,隨便給點思路。
      

  3.   

    非常感谢 fengjsSoft  的帮助,但我按您的说法添加代码后点击选择框并没有执行代码,不知道是什么原因?procedure Tdfcgtpc.DBGridEh1CheckButton(Sender: TObject; ACol: Integer;
      Column: TColumnEh; var Enabled: Boolean);
    var
          i:   Integer;
    begin
        for   i:=   3   to   DBGridEh1.FieldCount-1   do
        begin
          //if   (DBGridEh1.FieldColumns[i].Field.DataType = ftBoolean)   then   
          // begin
                showmessage('测试');
          //  end;
        end;
    end;并且if   (DBGridEh1.FieldColumns[i].Field.DataType = ftBoolean)   then   //这一句报错incompatible types 'String' and 'integer'
      

  4.   

    procedure   Tdfcgtpc.DBGridEhCellClick(Cloum:TCloum) 
    var 
      I: integer; 
    begin 
      for i := 0 to DBGridEh.FieldsCount - 1  do 
      begin 
        if DBGridEh.Field[i].DataType = ftBoolean   then 
        begin 
          if DBGridEh.Field[i].FieldName <> Cloum.FieldName then 
          begin 
            if DBGridEh.DataSource.Dataset.State in ([dsInsert,dsEdit])  then 
              DBGridEh.Field[i].asBoolean := False; 
          end; 
        end;
      end;     
    end; 
    上次給的代碼只是點思路,沒有調試, FieldColumns[i] 應該用Field[i]
    DBGridEh1CheckButton(Sender...)事件 應該用CellClick(Cloum:TCloum), 
    這次給的代碼應該是你所要的。在我本機上可以通過。
      

  5.   

    非常感谢   fengjsSoft     的帮助和各位的关注! 问题已经解决! 该结帖了!