DBGridEh里面如何让在按回车的时候在一个一个Cell里面浏览?(50分)

C

caochen

Unregistered / Unconfirmed
GUEST, unregistred user!
如果是最后一个Cell,并且下面还有记录,就继续浏览到下一条第一个Cell;
如果没有记录,并且数据集处于修改状态,则新增记录?这个功能如何实现?
大家不知道懂我得意思没有?
 
if not(dghEnterAsTab in DBGrid.OptionsEh) then
DBGrid.OptionsEh := DBGrid.OptionsEh + [dghEnterAsTab]
 
我已经设置了dghEnterAsTab为True,是不是其他属性还要设置?谢谢
 
不需要呀,我就这样用的,
 
首先设置Form1的KeyPreView为True,窗体上有Table、DBGridEh、DataSource。在窗体的KeyPress事件中写入下面的代码

if key = #13 then
if (activecontrol is TDBGridEh) then
begin
with tdbgrideh(activecontrol) do
if selectedindex < (fieldcount - 1) then
selectedindex := selectedindex + 1
else
begin
Table1.Append;
selectedindex := 0;
end;
end;
 
借個地方問問,各位大哥,如何對與dbgrideh關聯的printdbgrideh實現橫設置,
我想通過程序設置。先謝了?
 
To:飘摇客:
DBGridEh1.SelectedIndex是增加了1,但是是下一条记录增加了1,为什么?谢谢
 
To:飘摇客:
DBGridEh1.SelectedIndex是增加了1,但是是下一条记录增加了1,为什么?谢谢
这个问题是在dghEnterAsTab为False的前提下,但是如果有多条记录,在最后一个Cell回车
后是新增一条记录,而不是浏览下一条,如何才能浏览下一条呢?并且如何在最后一条记录
的最后一个Cell上回车时才新增记录?
 
改成这样就行了。

if key = #13 then
if (activecontrol is TDBGridEh) then
begin
with tdbgrideh(activecontrol) do
if selectedindex < (fieldcount - 1) then
selectedindex := selectedindex + 1
else
begin
dbgrideh1.DataSource.DataSet.Next;
if dbGridEh1.DataSource.DataSet.Eof then
Table1.Append;
selectedindex := 0;
end;
end;
 
谢谢大家
 
顶部