高分求DBGridEh控件的定制(300分)

  • 主题发起人 主题发起人 胡鸣
  • 开始时间 开始时间

胡鸣

Unregistered / Unconfirmed
GUEST, unregistred user!
我用的是EhLib 4.2.16,在这个版本中可以通过代码设置DBGridEh的RowCount,也可以在通过代码设置网格线的颜色,代码如下:
procedure TForm.DBGridEh1DrawColumnCell(Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumnEh;
State: TGridDrawState);
begin
with (Sender as TDBGrideh).Canvasdo

begin
Pen.Color := clred;
MoveTo(Rect.Left, Rect.Bottom);
LineTo(Rect.Right, Rect.Bottom);
MoveTo(Rect.Right, Rect.Top);
LineTo(Rect.Right, Rect.Bottom);
end;
end;
我想派生一个新的DBGridEh控件,新增上面两个属性,在设计时可用,请给一个的代码。
 
没人知道吗?
 
谢谢你这段代码,受用了,
不过这样写也有个问题,表格好闪,
 
好象没有什么用的说
class TDBGridEhX=TDBGridEh
private
FCellLineColor:TColor;
published
property cellLineColor :Tcolor read GetCellLineColor write SetCellLinecolor;
procedure DrawColumnCell(Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumnEh;
State: TGridDrawState);override;//如果ehlib 是非virtual ,可能需要修改?

end;
procedure DBGridEhX.GetCellLineColor:Tcolor;
begin
result := FCellLineColor ;
end;

procedure DBGridEhX.setCellLineColor(Thecolor:Tcolor);
begin
FCellLineColor := Thecolor;
end;

procedure DBGridEhX.DrawColumnCell(Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumnEh;
State: TGridDrawState);
begin
with (Sender as TDBGrideh).Canvasdo

begin
Pen.Color := FCellLineColor;
MoveTo(Rect.Left, Rect.Bottom);
LineTo(Rect.Right, Rect.Bottom);
MoveTo(Rect.Right, Rect.Top);
LineTo(Rect.Right, Rect.Bottom);
end;
end;

其他内容自己补充.
 
楼上的朋友, procedure DrawColumnCell(Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumnEh;
State: TGridDrawState);override;//如果ehlib 是非virtual ,可能需要修改?
其中TGridDrawState出现错误。
 
下列代码错在何处,请哪位高手指点一下。
unit Grid;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, DBGridEh;
type
MyGrid = class(TDBGridEh)
private
FCount: integer;
procedure SetCount(value: integer);
protected
procedure Paint;
override;
public
constructor Create(AOwner: TComponent);
override;
published
property RowsCount: Integer read FCount write SetCount;
end;

procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Standard', [MyGrid]);
end;

constructor MyGrid.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
RowCount := 10;
{ default values }
inherited;

end;

procedure myGrid.Paint;
var
RowCountBackup: Integer;
begin

RowCount := RowsCount;//设为此死机,如设为如RowCount:=1000具体数则能正常运行,如何调用参数?
inherited;
end;

procedure MyGrid.SetCount(Value: integer);
begin
FCount := Value;
end;
 
300分发不出去了啊!
 
procedure myGrid.Paint;
var
RowCountBackup: Integer;
begin

RowCount := FCount;
inherited;
end;
 
多人接受答案了。
 
后退
顶部