用DBGrid的时候,我们通常设一个SELECTED复选框做指针,
我现在有业务需要让这个复选框变成单选的,也就是只要实现互斥就可以了,就是选另中一个,前一个就取消选中
有什么办法吗

解决方案 »

  1.   

    自己写下事件清空已选中的那个Selected.procedure TForm1.CheckBox2Click(Sender: TObject);
    begin
      CheckBox1.Selected := False;
    end;
      

  2.   

    很好解决,选中时,记住这个记录的id,然后通过update其他记录为false,然后刷新记录集
      

  3.   

    簡單:
    在數據庫中作一個flag的字段值,可通過0或1去控制是否有選中;無論是單選或復選(或while循環),加上你的flag條件值,update後再Refresh...
    if lst_sel.IndexOf(qry_lz.FieldByName('Auid').AsString)<0 then
      begin
        lst_sel.Add(qry_lz.FieldByName('Auid').AsString);
        if VarToStr(cxGrid1DBBandedTableView1.Controller.FocusedRow.Values[1])<>'True' then
          cxGrid1DBBandedTableView1.Controller.FocusedRow.Values[1]:=True;
      end;