我是想用ListView来显示数据库数据,我希望通过getbook得到当前记录
在添加按钮中: AdodatasetStudent_1.Insert ;
在提交按钮中: ListItem := ListView1.Items.Add;
ListItem.Caption := AdodatasetStudent_1.FieldValues['学号'];
ListItem.SubItems.Add(AdodatasetStudent_1.FieldValues['姓名']);
ListItem.SubItems.Add(AdodatasetStudent_1.FieldValues['性别']);
ListItem.Data := AdodatasetStudent_1.GetBook;//结果
经过测试AdodatasetStudent_1.GetBook为nil为什么,如何
得到当前记录行
AdodatasetStudent_1.Post;
//ListView的SelectItem事件,我是想当鼠标点击新增加的这条记录的时候能够在
DBEidt控件里边显示出来,也就是说能找到当前的book,但是实际上得到的是nil
难道新增的得不到book,那么如何得到当前记录在DBEdit上显示呢?
procedure TFrmStudent_1.ListView1SelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
var
StudentKey:^OnekeyRec;
StuDentNum:integer;
begin
inherited;
if selected then
begin
AdoStudent_1.GotoBook(Listview1.Selected.Data);
end
else
begin
AdoStudent_1.GotoBook(NIl);
ClearRec;
UpdateDate(False);
end;
end;
在添加按钮中: AdodatasetStudent_1.Insert ;
在提交按钮中: ListItem := ListView1.Items.Add;
ListItem.Caption := AdodatasetStudent_1.FieldValues['学号'];
ListItem.SubItems.Add(AdodatasetStudent_1.FieldValues['姓名']);
ListItem.SubItems.Add(AdodatasetStudent_1.FieldValues['性别']);
ListItem.Data := AdodatasetStudent_1.GetBook;//结果
经过测试AdodatasetStudent_1.GetBook为nil为什么,如何
得到当前记录行
AdodatasetStudent_1.Post;
//ListView的SelectItem事件,我是想当鼠标点击新增加的这条记录的时候能够在
DBEidt控件里边显示出来,也就是说能找到当前的book,但是实际上得到的是nil
难道新增的得不到book,那么如何得到当前记录在DBEdit上显示呢?
procedure TFrmStudent_1.ListView1SelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
var
StudentKey:^OnekeyRec;
StuDentNum:integer;
begin
inherited;
if selected then
begin
AdoStudent_1.GotoBook(Listview1.Selected.Data);
end
else
begin
AdoStudent_1.GotoBook(NIl);
ClearRec;
UpdateDate(False);
end;
end;
解决方案 »
- There is no default printer currently selected
- delphi中的LISTVIEW怎么与数据库连接
- .les文件用什么打开呀?
- ToolBar组件上的疑惑
- 请教大家 如何使用ADOQuery的结果啊
- 为什么我的程序到别人的机子上一运行就非法操作呢?
- 冲星星,还差1xx分,散分!up有分
- 程序编译时出现cannot debug project unless a host application is defined.
- 怎样实现鼠标拖动image的效果?
- 请教一个SERVERSOCKET的线程问题,分数上限3000
- 在厦门找个程序员工作怎么这么难?
- 关于memo或richtext
但是为什么写在afterpost里比较好呢,
因为我的post是写在提交按钮里的,而这个按钮还要做更新的的事件