关于TDBNavigator图标变成文字或显示文字的问题??(50分)

  • 主题发起人 主题发起人 diamondpantene
  • 开始时间 开始时间
D

diamondpantene

Unregistered / Unconfirmed
GUEST, unregistred user!
TDBNavigator控件上一般只有图标,没有文字说明,而Hint属性又不方便,
所以我想能不能在TDBNavigator的按钮上既显示图标又显示文字或只显示
文字!请问该怎么办??
 
unit DBNavPlus;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, DBCtrls, Buttons;

const
DBNavPlusVersion = '1.2';

type
TDBNavPlus = class(TDBNavigator)
private
{ Private declarations }
DoCaptions: boolean;
FCaptions: TStrings;
FLayout: TButtonLayout;
FSpacing: Integer;
FMargin: Integer;
protected
{ Protected declarations }
procedure SetLayout(value: TButtonLayout);
procedure SetSpacing(value: integer);
procedure SetMargin(value: integer);
procedure SetCaptions(value: TStrings);
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property Captions: TStrings read FCaptions write SetCaptions;
property Layout: TButtonLayout read FLayout write SetLayout default blGlyphTop;
property Spacing: Integer read FSpacing write SetSpacing default 2;
{if we dont set default, the SetMargin is called}
{this will allow us to put the SetCaptions in as it is not called!}
property Margin: Integer read FMargin write SetMargin;
property Font;
end;

procedure Register;

implementation

const
DefaultCaption: array[0..9] of string =
('首笔','上笔','下笔','末笔','新增',
'删除','编辑','存盘','取消','刷新');

{******************************************************************************}
constructor TDBNavPlus.Create(AOwner: TComponent);
var
x: integer;
begin
inherited create(AOwner);
{initialize values}
FCaptions := TStringList.create;
DoCaptions := True;
FSpacing := 0;
SetSpacing(2);
FMargin := 0;
SetMargin(-1);
FLayout := blGlyphBottom;
SetLayout(blGlyphTop);
FCaptions.Clear;
for x := 0 to 9 do FCaptions.Add(DefaultCaption[x]);
SetCaptions(FCaptions);
end; {of Create}

{******************************************************************************}
destructor TDBNavPlus.Destroy;
begin
FCaptions.Free;
inherited Destroy;
end; {of destroy}

{******************************************************************************}
procedure TDBNavPlus.SetCaptions(Value: TStrings);
var
t: TNavigateBtn;
begin
{set captions or default if not assigned}
if Value <> FCaptions
then FCaptions.Assign(Value);
for t:= low(TNavigateBtn) to high(TNavigateBtn) do begin
if ord(t) < Value.Count
then Buttons[t].caption := Value[ord(t)]
else Buttons[t].caption := DefaultCaption[ord(t)];
end;
Invalidate;
end; {of setCaptions}

{******************************************************************************}
procedure TDBNavPlus.SetLayout(value: TButtonLayout);
var
t: TNavigateBtn;
begin
if (value = Flayout) and not (csLoading in ComponentState) then exit;
FLayout := value;
for t:= low(TNavigateBtn) to high(TNavigateBtn)
do Buttons[t].Layout := value;
Invalidate;
end; {of SetLayout}

{******************************************************************************}
procedure TDBNavPlus.SetSpacing(value: integer);
var
t: TNavigateBtn;
begin
if (value = FSpacing) and not (csLoading in ComponentState) then exit;
FSpacing := value;
for t:= low(TNavigateBtn) to high(TNavigateBtn)
do Buttons[t].Spacing := value;
Invalidate;
end; {of SetSpacing}

{******************************************************************************}
procedure TDBNavPlus.SetMargin(value: integer);
var
t: TNavigateBtn;
begin
if (value = FMargin) and not (csLoading in ComponentState) then exit;
if (csLoading in ComponentState) then SetCaptions(FCaptions);
FMargin := value;
for t:= low(TNavigateBtn) to high(TNavigateBtn)
do Buttons[t].margin := value;
Invalidate;
end; {of SetMargin}


{******************************************************************************}
procedure Register;
begin
RegisterComponents('Fitco', [TDBNavPlus]);
end; {of Register}

end.
 
哪有这个复杂啊!!!!!
type
TDBNavPlus = class(TDBNavigator)


var
my:TDBNavigator;
在窗体创建中写
TDBNavPlus(my).Buttons[nbFirst].Caption:='首记录';
TDBNavPlus(my).Buttons[nbPrior].Caption:='向上';
TDBNavPlus(my).Buttons[nbNext].Caption:='向下';
TDBNavPlus(my).Buttons[nbLast].Caption:='尾记录';
TDBNavPlus(my).Buttons[nbInsert].Caption:='插入';
TDBNavPlus(my).Buttons[nbDelete].Caption:='删除';
TDBNavPlus(my).Buttons[nbEdit].Caption:='编辑';
TDBNavPlus(my).Buttons[nbPost].Caption:='提交';
TDBNavPlus(my).Buttons[nbCancel].Caption:='取消';
TDBNavPlus(my).Buttons[nbRefresh].Caption:='刷新';
 
多人接受答案了。
 

Similar threads

回复
0
查看
1K
不得闲
S
回复
0
查看
675
SUNSTONE的Delphi笔记
S
S
回复
0
查看
651
SUNSTONE的Delphi笔记
S
D
回复
0
查看
767
DelphiTeacher的专栏
D
后退
顶部