請問各位大俠﹐能告訴我在DBGRID裡面加一個單選框嗎﹖不勝感激

解决方案 »

  1.   

    自己画吧,给你一点门路:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      DBGrid1.DefaultDrawing:=False;
      //或直接设置DBGrid的DefaultDrawing属性为False;
    end;
    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
      if Column.FieldName='CHECKFIELD' then
      begin
        if True or (Column.Field.AsString='Y') then
        begin
          DBGrid1.Canvas.FillRect(rect);
          DBGrid1.Canvas.MoveTo (Rect.Left,Rect.Top);
          DBGrid1.Canvas.LineTo (Rect.Left+8,Rect.Top+8);
          DBGrid1.Canvas.LineTo (Rect.Left+20,Rect.Top);
          {OR:
          DBGrid1.Canvas.Draw(Rect.Left+2,Rect.Top+2,TGraphic(ImgCheck));//image of Checked
          }
        end else
        begin
          DBGrid1.Canvas.FillRect(rect);
          {OR:
          DBGrid1.Canvas.Draw(Rect.Left+2,Rect.Top+2,TGraphic(ImgUnCheck)); //image of UnChecked
          }
        end;
      end else
      begin
        DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
      end;
    end;要好看,且点击它时自然,还要加一些辅助代码。按自己实际需要修改吧.
      

  2.   

    "if True or (Column.Field.AsString='Y') then"---供测试,实际应用应改为:
     if (Column.Field.AsString='Y') then
     
      

  3.   

    去查一下“在dbgrid中加入可视化控件”方面的文章吧。