刚才发掉80分,再加80,不能解决这个问题,以后的贴子不结。

My_first 2002-07-09 12:12:49
如何去掉dbgrid标题之间的间格线。同时表格的网格线又存在。
http://www.csdn.net/expert/topic/860/860169.xml?temp=3.445071E-02

为了这个问题我花了400分。 现在还没结贴。谁能解决。
...全文
39 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
webnumen 2002-07-09
  • 打赏
  • 举报
回复
属性里面根本没办法解决哦,只有重画控件。
My_first 2002-07-09
  • 打赏
  • 举报
回复
通过重画该怎么做。
My_first 2002-07-09
  • 打赏
  • 举报
回复
通过重画该怎么做。
neilwq 2002-07-09
  • 打赏
  • 举报
回复
你这样做的目的是什么?
yansea 2002-07-09
  • 打赏
  • 举报
回复
简单一点,用tpanel覆盖掉标题栏,不过在滚屏是不好控制;
zhouzm 2002-07-09
  • 打赏
  • 举报
回复
这好像要重新改写组件,不能从TCustomGrid继承,而应该从TCustomControl继承,你试试改写一下!
netlib 2002-07-09
  • 打赏
  • 举报
回复
如果通过属性解决不了,建议自己写个类,从dbgrid继承。
重载重画事件即可。
kories 2002-07-09
  • 打赏
  • 举报
回复
不客气,大家互相帮忙,分更是无所谓(估计我是没法子挣到那么多星的^_^)。

我把程序给调坏了。
我用的是ehlib, 我想把上面的代码继承 DBGridEh
但就是调不出来。你能帮我吗?

我不太清楚你的意思,DELPHI我现在用的不多了,数据库程序更是不大做了,ehlib好象是报表组件,和这有关?为什么还要继承一层?但就是调不出来?请解释清楚一点,你可以EMAIL联系我,我来找个东西,不会老来看帖子的。kories@163.net,欢迎讨论技术问题。
My_first 2002-07-09
  • 打赏
  • 举报
回复
分不够我再加120。可以另开贴
My_first 2002-07-09
  • 打赏
  • 举报
回复
是的,你的这段程序通过了。 谢谢你,太感谢你了。 但是我把程序给调坏了。
我用的是ehlib, 我想把上面的代码继承 DBGridEh

但就是调不出来。你能帮我吗?
kories 2002-07-09
  • 打赏
  • 举报
回复
什么问题?这不是最好的办法,但该能解决问题呀,我调试过的。
My_first 2002-07-09
  • 打赏
  • 举报
回复
to kories(老实疙瘩) 你好!

你在线吗?
kories 2002-07-09
  • 打赏
  • 举报
回复
unit KDBGrid;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, Grids, DBGrids, Dialogs, ExtCtrls ,StdCtrls;

type
TKDBGrid = class(TDBGrid)
private
FTitlePanel : TPanel;
FSpecialTitle : Boolean;
FLastLeftCol : Integer;
procedure SetSpecialTitle(Value : Boolean);
procedure SetTitlePanelStatus;
function CellsTotalWidth : Integer;
protected
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
procedure ColWidthsChanged; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property SpecialTitle : Boolean read FSpecialTitle write SetSpecialTitle;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Kories', [TKDBGrid]);
end;

{ TKDBGrid }

constructor TKDBGrid.Create(AOwner: TComponent);
begin
inherited;
FTitlePanel := TPanel.Create(Self);
FLastLeftCol := 0;
SetTitlePanelStatus;
end;

destructor TKDBGrid.Destroy;
begin
FTitlePanel.Free;
inherited;
end;

function TKDBGrid.CellsTotalWidth: Integer;
var
I : Integer;
begin
Result := 0;
for I := 0 to Self.Columns.Count - 1 do
Result := Result + Self.Columns[I].Width + Self.GridLineWidth;
Result := Result + (Self.CellRect(0,0).Right - Self.CellRect(0,0).Left);
end;

procedure TKDBGrid.ColWidthsChanged;
begin
inherited;
SetTitlePanelStatus;
end;

procedure TKDBGrid.DrawCell(ACol, ARow: Integer; ARect: TRect;
AState: TGridDrawState);
begin
inherited;
if Self.LeftCol <> FLastLeftCol then begin
SetTitlePanelStatus;
FLastLeftCol := Self.LeftCol;
end;
end;

procedure TKDBGrid.SetSpecialTitle(Value: Boolean);
begin
if Value <> FSpecialTitle then
FSpecialTitle := Value;
end;

procedure TKDBGrid.SetTitlePanelStatus;
function GetLabelLeft(Count : Integer) : Integer;
var
I ,MyWidth : Integer;
begin
MyWidth := 0;
Result := 0;
for I := 0 to Count - 1 do
MyWidth := MyWidth + Self.Columns[I].Width + Self.GridLineWidth;
MyWidth := MyWidth + (Self.CellRect(0,0).Right - Self.CellRect(0,0).Left);
Result := MyWidth;
end;
//
function GetPanelLeft : Integer;
var
I : Integer;
begin
Result := 0;
for I := 0 to Self.LeftCol - 2 do
Result := Result + Self.Columns[I].Width + Self.GridLineWidth;
Result := 0 - Result;
end;
var
I : Integer;
MyLabel : TLabel;
begin
if not FSpecialTitle then begin
FTitlePanel.Visible := False;
Exit;
end;
//
with FTitlePanel do begin
Parent := Self;
Visible := False;
Width := CellsTotalWidth;
Height := Self.CellRect(0,0).Bottom - Self.CellRect(0,0).Top;
Left := GetPanelLeft;
Top := 0;
Visible := True;
end;
for I := FTitlePanel.ComponentCount -1 downto 0 do
if FTitlePanel.Components[I] is TLabel then TLabel(FTitlePanel.Components[I]).Free;
for I := 0 to Self.Columns.Count - 1 do begin
MyLabel := TLabel.Create(FTitlePanel);
MyLabel.Parent := FTitlePanel;
MyLabel.Top := Round((FTitlePanel.Height - MyLabel.Height)/2) + 1;
MyLabel.Font := Self.Columns[I].Title.Font;
MyLabel.Left := GetLabelLeft(I);
MyLabel.Caption := Self.Columns[I].Title.Caption;
MyLabel.Visible := True;
end;
end;

end.

{
请使用此组件,将SpecialTitle属性设为True就是你要的效果。
在D6 + Win2K下调试正常,写的很仓促,有什么问题再联系我。
}

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧