請教各位高手,如何將記錄號加到dbgrid 中? delphi / windows sdk/api
下面我的dbgrid中顯示的**,如何將記錄號加到dbgrid 列中,謝謝了!
qq1:=tadoquery.create(self);
qq1.connection:=conn;
with qq1 do
begin
close;
sql.clear;
sql.add('select id,haoma as 號碼,guishu as 歸屬地,tongxunming as 通訊公司 from haoma ');
open;
end;
datasource1.dataset:=qq1;
dbgrid1.datasource:=datasource1;
id 不就是記錄號麼
id 只是資料庫中的乙個自動編號,不一定是從1開始,按依次加1的順序往下走的
procedure tdbgrideh.drawcell(acol:integer;arow:integer;arect:trect;astate:tgriddrawstate);
var
i,dbrow,lleft:integer;
icol,irow:integer; //全域性變數
begin
inherited;
if fshowrecno=true then
begin
if assigned(datalink) and
datalink.active then //沒有open
begin
if (arow>=1) and
(acol=0) then
begin
i := 0;//偏移值
lleft := 0;//居中顯示
dbrow := self.datasource.dataset.recno;//當前資料集所在的行標 rec no
if datasource.dataset.recno=-1 then
begin
dbrow := datasource.dataset.recordcount+1;//當前行標取記錄總數+1
end;
i := dbrow - self.row ;//計算**toprow和資料集所在行的偏移值(顯示實際資料集行號)
lleft := (arect.right - arect.left) div 2 - canvas.textwidth(inttostr(arow+i)) div 2;//居中顯示
canvas.textrect(arect,arect.left+lleft,arect.top,inttostr(arow+i));//輸出行號
end;
end;
end;
end;
1、在dbgrid中增加一列,列名的抬頭比如說是'序號'
2、**:
procedure tform1.dbgrid1drawcolumncell(sender: tobject; const rect: trect;
datacol: integer; column: tcolumn; state: tgriddrawstate);
begin
if datasource1.dataset.recno > 0 then
begin
if wideuppercase(column.title.caption) = '序號' then
dbgrid1.canvas.textout(rect.left + 2, rect.top, inttostr(datasource1.dataset.recno));
end;
end;
好麻煩.
結貼
如何 將項新增到快取中
可以使用 cache 物件訪問應用程式快取中的項。可以使用 cache 物件的 insert 方法向應用程式快取新增項。該方法向快取新增項,並且通過幾次過載,您可以用不同選項新增項,以設定依賴項 過期和移除通知。如果使用 insert 方法向快取新增項,並且已經存在與現有項同名的項,則快取中的現有項...
如何 將項新增到快取中
可以使用 cache 物件訪問應用程式快取中的項。可以使用 cache 物件的 insert 方法向應用程式快取新增項。該方法向快取新增項,並且通過幾次過載,您可以用不同選項新增項,以設定依賴項 過期和移除通知。如果使用 insert 方法向快取新增項,並且已經存在與現有項同名的項,則快取中的現有項...
如何將專案新增到git上
1 cd 到你要新增的專案資料夾中 2 使用命令 git init 注 將你的目錄管理成git倉庫 就是初始化git 3 使用命令 git add 注意一定要加點哦 注 將你的檔案新增到git庫中 4 使用命令 git commit m 你的備註檔案 注 將你的檔案提交到git倉庫中,然後備註你提交...