如何在DBGird点选ROW时在TEXT1,2里显示其对应的数值,
新手急等,请各位大大详细点,谢谢,必送分。

解决方案 »

  1.   

    with Dbgrid.DataSource.DataSet do
    begin
       Text1.Text := FieldByName('字段名').asString;
       Text2.Text := FieldByName('字段名').asString;
    end;
      

  2.   

    procedure TForm1.DBGrid1CellClick(Column: TColumn);
    begin
      Text1.Text :=  DBGrid1.DataSource.DataSet.FieldByName('字段名').asstring;
      Text2.Text :=  DBGrid1.DataSource.DataSet.FieldByName('字段名').asstring;
    end;
      

  3.   

    procedure TForm1.DBGrid1CellClick(Column: TColumn);
    begin
      Text1.Text :=  DBGrid1.DataSource.DataSet.FieldByName('字段名').asstring;
      Text2.Text :=  DBGrid1.DataSource.DataSet.FieldByName('字段名').asstring;
    end;
     
      

  4.   

    这个好象不能达到要求,我想要的不是单独去点击某项来单独显示,而是想得到的效果是点击一项时在DBGRID里的所有自段都自动添加到TEXT1,TEXT2。谢谢
      

  5.   

    procedure TForm1.DBGrid1CellClick(Column: TColumn);
    begin
      Text1.Text := '';
      Text2.Text := '';
      DBGrid1.DataSource.DataSet.First;
      while not(DBGrid1.DataSource.DataSet.eof) do
      begin
        Text1.Text :=  Text1.Text + DBGrid1.DataSource.DataSet.FieldByName('字段名').asstring;
        Text2.Text :=  Text2.Text + DBGrid1.DataSource.DataSet.FieldByName('字段名').asstring;
        DBGrid1.DataSource.DataSet.Next;
      end;
    end;
      

  6.   

    zwb666(zwb)的可以呀,你需要哪些字段就取哪些字段赋给EDIT就可以了
      

  7.   

    procedure TForm1.DBGrid1CellClick(Column: TColumn);
    begin
      Text1.Text :=  DBGrid1.DataSource.DataSet.FieldByName('xx').asstring;
      Text2.Text :=  DBGrid1.DataSource.DataSet.FieldByName('xx').asstring;
    end;
      

  8.   

    meiqingsong(阿飛) 的方法可以
      

  9.   

    procedure TForm1.DBGrid1CellClick(Column: TColumn);
    begin
      Text1.Text :=  DBGrid1.DataSource.DataSet.FieldByName('字段名').asstring;
      Text2.Text :=  DBGrid1.DataSource.DataSet.FieldByName('字段名').asstring;
    end;
    //这样就行