怎样在dbgrid中双击某行将这行所对应的数据字段的值复制给相应的edit 怎样在dbgrid中双击某行将这行所对应的数据字段的值复制给相应的edit,如有5个字段,其对应的edit分别是edit1,edit2,edit3...edit5; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在双击事件中写:edit1.text:=query1.fieldbyname('field').asstring; procedure TForm1.DBGrid1DblClick(Sender: TObject);beginedit1.text:=query1.fieldbyname('field').asstring;end; 针对小飞侠的补充一下: case dbgrid.selectedfield.index of 0: begin edit1.text:=table.field[0].asstring; end; 1: ; .. n: ; end;//end of case 其中的n为字段个数减1. procedure TForm1.DBGrid1DblClick(Sender: TObject);begin case dbgrid.selectedfield.index of 0: begin edit1.text:=table.fieldbyname('name').asstring; end; 1: ; .. n: ; end;//end of case 其中的n为字段个数减1.end; edit1.text:=query1.fieldbyname('field').asstring; 我想你可以这样去理解,那就是当你使用dbgrid时如果要操作你都是对它所对用的dagasource或者也可以是直接的dataset来进行操作。因为你在dbgrid中的行的移动也会使数据库的cursor移动。你直接存取数据库中的当然记录就可以了。 为什么我的程序打包之后在别的电脑上不好使 有没有办法判断一个类或对象,是否override它的父类的某一个方法? 如何使edit控件只能输入数字,不能输入其它字符? 求DataSnap页中的DCOMConnection 控件的详解? 急问三层的问题,请帮忙!!!! 求助!! 如何动态的创一个报表 如何用copyfile函数恢复数据库文件?是不是和备份时一样?只不过目标文件与原文件和备份时相反? help me!!!! 问题``ERROR 打印预览的报表中的字有重叠 关于dbgrid控件的控件问题
edit1.text:=query1.fieldbyname('field').asstring;
begin
edit1.text:=query1.fieldbyname('field').asstring;
end;
case dbgrid.selectedfield.index of
0: begin
edit1.text:=table.field[0].asstring;
end;
1: ;
..
n: ;
end;//end of case
其中的n为字段个数减1.
begin
case dbgrid.selectedfield.index of
0: begin
edit1.text:=table.fieldbyname('name').asstring;
end;
1: ;
..
n: ;
end;//end of case
其中的n为字段个数减1.
end;