现有一StringGrid,其以显示了数据,现想当用鼠标点击某一行时,可以将该行的某一列的数据读出来,如何解决这个问题?

解决方案 »

  1.   

    比如要取第3列的值
    stringgrid的名字为sG_sample
    var
      Selval:string;
      RowCount:integer;
    begin
      RowCount:=.Selection.top;
      SelVal:=Sg_Sample.cells[2,Rowcount];
    end;
      

  2.   

    look:http://218.56.11.178:8020/web/index.aspx->软件基地->源码-》delphi/kylix->StringGrid控件的使用
      

  3.   

    把那个标签的CAPTION当你的 变量就可以了
      

  4.   

    比如要取第3列的值
    stringgrid的名字为sG_sample
    var
      Selval:string;
      RowCount:integer;
    begin
      RowCount:=.Selection.top;
      SelVal:=Sg_Sample.cells[2,Rowcount];
    end;
      

  5.   

    用stringgrid1.row
    第3列的值:
    stringgrid1.cells[2,stringgrid1.row];
      

  6.   

    在onclick事件里写,davidkaixin(大卫)的代码,应该可以实现!
    你式式!
      

  7.   

    procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
      ARow: Integer; var CanSelect: Boolean);
    begin
        ShowMessage(StringGrid1.Cells[ACol,ARow]);
    end;
      

  8.   

    procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
      ARow: Integer; var CanSelect: Boolean);
    begin
      if CanSelect then
        showmessage(StringGrid1.Cells[ACol,ARow]);
    end;
      

  9.   

    procedure TForm1.StringGrid1Click(Sender: TObject);
    var
      strTemp:string;
    begin
      strTemp:=StringGrid1.Cells[2,StringGrid1.Row];//2 为列
      ShowMessage(strTemp);
    end;