急等   单击DBGrid某一行如何获取该行某一字段值

解决方案 »

  1.   

    (sender as TAdoDataset).fields[i].value
      

  2.   

    procedure TForm5120.DBGrid1CellClick(Column: TColumn);
    var
      i:integer;
    begin
      if ADOQuery1.Active then
        for i := 0 to ADOQuery1.FieldCount do
          ShowMessage(ADOQuery1.Fields.Fields[i].AsString);    
    end;
      

  3.   

    以上代码在dbgrid的oncellclick事件中加入
      

  4.   

    dbgrid1.Fields[/*选中行字段的索引号*/].Value
    例:
    dbgrid1.Fields[Table1.FieldByName('LAST_NAME').Index].Value
      

  5.   

    只要弄明白一个概念就清楚了,DBGrid只是前段显示,后端总是Dataset在起作用,直接用Dataset的字段取值就行了嘛
      

  6.   

    Edit1.text := adoquery1.fieldbyname('你要的字段名称').value;