在delphi中的DBGrid中怎样得到某一行的一个字段的值?,最好举个例子。
谢谢大家!

解决方案 »

  1.   

    DBGrid.selectrows.fields[i].asstring,看看
      

  2.   

    table1.fieldbyname('fieldname').asstring;
      

  3.   

    get the value of a field of the current row
      

  4.   

    DBGrid.DataSource.DataSet.FieldByName('字段').AsString;
      

  5.   

    首先定位记录
    然后获得记录值楼上的方法基本上都是获得的第一条的记录值
    并非楼主所需
    定位记录使用 moveby  locate 等函数
      

  6.   

    对 楼上的办法都是获得当前记录的 字段值  要先定位   用QUERY吧  灵活的多
      

  7.   

    1。
    locate 到指定行2。
    adoquery1.field[n].value就是你要的东东了
    n为你想要的行数
      

  8.   

    to:lufancy(同志)
    举例
        在DBGrid控键中,对应一张表,比如:dept
        dept中有三个字段:deptid,deptname,re
        dept表中假设有10条记录,
        单击任意一行,即可得到当前行主键(deptid)的值。