書本上的例子,但是運行不了,,
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in [#13]) then
if not frmlookup.showing then
begin
frmlookup.left:=TMydbgrid(dbgrid1).GetCellRect.left;
frmlookup.top:=tmydbgrid(DBGrid1).getcellrect.bottom;
frmlookup.show;
end;
if Key=#13 then
begin
if DBGrid1.SelectedIndex<DBGrid1.Columns-1 then //選中的行數沒在最后一行
begin
DBGrid1.SelectedIndex:=DBGrid1.SelectedIndex+1;
end
else
begin
if DBGrid1.DataSource.DataSet.RecNo<DBGrid1.DataSource.DataSet.RecordCount then
begin
DBGrid1.DataSource.DataSet.RecNo:=DBGrid1.DataSource.DataSet.RecNo+1;
end
else
begin
DBGrid1.DataSource.DataSet.Append;
end;
DBGrid1.SelectedIndex:=0;
end;
end;
end;
其中的
if not frmlookup.showing then
begin
frmlookup.left:=TMydbgrid(dbgrid1).GetCellRect.left;
frmlookup.top:=tmydbgrid(DBGrid1).getcellrect.bottom;
frmlookup.show;
中的frmlookup,是變數嗎?還是,,,小弟看不懂這一段???
還有RecNo跟RecordCount 該怎么理解好??
uj5u.com熱心網友回復:
你要實作回車換行增加行,下面那段代碼就可以實作了。運行出錯就把這段代碼注釋掉。
frmlookup貌似是一個表單
uj5u.com熱心網友回復:
frmlookup應該是一個表單,按住ctrl再點擊看看跳到哪里...uj5u.com熱心網友回復:
帶有frmlookup的都會報錯,那那段代碼注釋之后,就
if DBGrid1.SelectedIndex<DBGrid1.Columns-1 then //選中的行數沒在最后一
這一句報錯
uj5u.com熱心網友回復:
這是我書本代碼,我自己敲上去的.....uj5u.com熱心網友回復:
因為你沒有frmlookup所以都會報錯。if DBGrid1.SelectedIndex<DBGrid1.Columns-1 then //選中的行數沒在最后一
這一句報什么錯帖出來
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/100422.html
標籤:語言基礎/算法/系統設計
