多谢各位帮忙了在该daagrid的DrawColumnCell事件的代码如下:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.Index = 0 then
with DBGrid1.Canvas do begin
FillRect(Rect);
TextOut(Rect.Left+2, Rect.Top+2, IntToStr(DBGrid1.DataSource.DataSet.RecNo));
end;
end;运行后在这一列的值却总是固定的值,请教各位大虾,该如何解决呢?
很急,解答完了,立即送分!
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.Index = 0 then
with DBGrid1.Canvas do begin
FillRect(Rect);
TextOut(Rect.Left+2, Rect.Top+2, IntToStr(DBGrid1.DataSource.DataSet.RecNo));
end;
end;运行后在这一列的值却总是固定的值,请教各位大虾,该如何解决呢?
很急,解答完了,立即送分!
解决方案 »
- DSPack播放压缩视频 SampleGrabber无法截图
- Ultra Edit Delphi语法加亮WordFile
- 文件保存问题
- 如何实现用idhttp断点续传
- IntraWeb在通过ado与access连接时的问题!
- 简单的打包问题???
- 大家给一个TFileStream逐行读取文件的代码,我急用的。
- 谁有dcomcnfg.exe for win98 的程序给我发一份(dcm98cfg.com),急用,谢了,邮箱:[email protected]
- 同等条件下,两层还是三层的访问数据库更快??
- 怎么ActiveSkin.ocx注册啦,但不能导入到Delphi中,总是说已经有一个 TSKINFORM 类安装啦,而且我的OCX控件装入后没有图标显示呢?
- 问一个 F1Book 的问题
- 有谁知道?
select rownum from table
table.fieldbyname('id').asinteger:=table1.recno+1
就可以了
无聊说得对,可这位仁兄好像刚学DELPHI,计算字段是在TTable里面夹的而不是DBGrid,
1.双击TTable
2.在出现的窗体中点右键,选择添加新字段
3.在弹出对话框中选择属性.
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.Index = 5 then
with DBGrid1.Canvas do begin
FillRect(Rect);
TextOut(Rect.Left+2, Rect.Top+2, IntToStr(DBGrid1.DataSource.DataSet.RecNo));
end;
end;
DBGrid object DBGrid1: TDBGrid
Left = 16
Top = 16
Width = 657
Height = 265
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
OnDrawDataCell = DBGrid1DrawDataCell
OnDrawColumnCell = DBGrid1DrawColumnCell
Columns = <
item
Expanded = False
FieldName = 'ID'
Visible = True
end
item
Expanded = False
FieldName = 'username'
Visible = True
end
item
Expanded = False
FieldName = 'userpass'
Visible = True
end
item
Expanded = False
FieldName = 'userpopedom'
Visible = True
end
item
Expanded = False
FieldName = 'userdq'
Visible = True
end
item
Expanded = False
Title.Caption = 'RecNo'
Visible = True
end>
end----------------------------------------------------------
等待,如沙漠行舟,痛苦万分
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.Title.Caption='NAME' then
begin
DBGrid1.Canvas.TextRect(Rect, Rect.Left, Rect.Top
+ 2,inttostr(DBGrid1.DataSource.DataSet.RecNo));
end; Application.ProcessMessages;
end;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.Title.Caption='NAME' then
begin
DBGrid1.Canvas.TextRect(Rect, Rect.Left, Rect.Top
+ 2,inttostr(DBGrid1.DataSource.DataSet.RecNo));
end;
end;