如何设置DBGRID的任意行、任意左右框线的任意颜色及线条粗细?如何限定DBGRID显示的行、列数?(50分)

  • 主题发起人 主题发起人 jonva
  • 开始时间 开始时间
J

jonva

Unregistered / Unconfirmed
GUEST, unregistred user!
如何设置DBGRID的任意行、任意左右框线的任意颜色及线条粗细?如何限定DBGRID显示的行、列数?
求教代码。
 
dxdbgrid有这个功能
 
TcxGrid for D7 功能強大,可以做到
 
你用dbgrid的canvas来画,想把dbgrid做成什么样子都可以。
 
能不能举个例子,给点代码,
 
procedure Tformsls2.DBGrideh1DragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
var
thistop,i,thisleft,thiswidth,thisheight: Integer;
begin
if source=sender then
begin
if currow<>DBgrideh1.MouseCoord(x,y).Y then
begin
accept:=true;
DBgrideh1.Invalidate;
currow:=DBgrideh1.MouseCoord(x,y).Y;
end;
if (DBgrideh1.MouseCoord(x,y).Y>0) and(thisrow<DBgrideh1.MouseCoord(x,y).Y)
then
begin
thistop:=0;
for i:=0 to thisrow-1 do
thistop:=thistop+Tstringgrid(DBgrideh1).RowHeights+1;
thisleft:=0;
for i:=Tstringgrid(DBgrideh1).LeftCol to Tstringgrid(DBgrideh1).Col-1 do
thisleft:=thisleft+Tstringgrid(DBgrideh1).ColWidths+1;
thiswidth:=thisleft+Tstringgrid(DBgrideh1).ColWidths[thiscol];
thisheight:=thistop;
for i:=thisrow to DBgrideh1.MouseCoord(x,y).Y do
thisheight:=thisheight+Tstringgrid(DBgrideh1).RowHeights+1;
DBgrideh1.Canvas.Brush.Style:=bsClear;
DBgrideh1.Canvas.Pen.Color:=clRed;
DBgrideh1.Canvas.Pen.Style:=psSolid;
DBgrideh1.Canvas.Rectangle(thisleft+10+2,thistop+1,thiswidth+10+1,thisheight+1);
end;
end;
end;
关键是你要找到坐标。
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部