procedure TForm1.DBGrid1DBLClick(Sender: TObject); begin ShowForm2(Table1.FieldByName('学好').Value); end; 在Form2中,添加一个共有方法.procedure TForm2.ShowForm2(Value: Variant); begin if not tblStudentInfo.Active then tblStudentInfo.Active := True; tblStudent.Locate('学号', Value, [loCaseInsensitive]); ShowMadal; end;
这时你可以用dbgrid1.fields.dataset.fieldbyname('字段').asstring取得记录值!
双击某一项,在form2中显示该纪录的详细信息(在表二中,显示个人信息),form2中我是用dbedit等设数据源与相关字段连接的。我想双击班级程源的某一项,显示给人详细信息.
建表时两个表应该如何设?双击后,应如何在form中显示表二中对应的纪录。
我第一次用数据库,希望您的指导能详细些!谢谢。
例如: edit_name.text:=dateset('姓名').value;
procedure TForm1.DBGrid1DBLClick(Sender: TObject);
begin
ShowForm2(Table1.FieldByName('学好').Value);
end;
在Form2中,添加一个共有方法.procedure TForm2.ShowForm2(Value: Variant);
begin
if not tblStudentInfo.Active then tblStudentInfo.Active := True;
tblStudent.Locate('学号', Value, [loCaseInsensitive]);
ShowMadal;
end;