Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Changing the TDBNavigator button images
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Question:
How can I change the TDBNavigator button images?
Answer:
Provide bitmap files 'first.bmp' etc (see code below; it assumes that the bitmaps are in the directory where the .exe file resides) and use the procedure ChangeDBNavImage like this:
ChangeDBNavImage(DBNavigator1);
The code looks through the child objects for the TNavButton and assigns each bitmap.  | |  | | procedure ChangeDBNavImage(DBnav: TDbNavigator);
var
i: integer;
tempGlyph: TBitmap;
ExePath: string;
begin
ExePath := ExtractFilePath(Application.ExeName);
tempGlyph := TBitmap.Create;
try
with DBnav do
begin
for i := 0 to ControlCount-1 do
begin
if Controls[i].ClassName='TNavButton' then
begin
case TNavButton(Controls[i]).index of
nbFirst:
tempGlyph.LoadFromFile(ExePath+'first.bmp');
nbPrior:
tempGlyph.LoadFromFile(ExePath+'previous.bmp');
nbNext:
tempGlyph.LoadFromFile(ExePath+'Next.bmp');
nbLast:
tempGlyph.LoadFromFile(ExePath+'Last.bmp');
nbInsert:
tempGlyph.LoadFromFile(ExePath+'Insert.bmp');
nbDelete:
tempGlyph.LoadFromFile(ExePath+'Delete.bmp');
nbEdit:
tempGlyph.LoadFromFile(ExePath+'Edit.bmp');
nbPost:
tempGlyph.LoadFromFile(ExePath+'Post.bmp');
nbCancel:
tempGlyph.LoadFromFile(ExePath+'Cancel.bmp');
nbRefresh:
tempGlyph.LoadFromFile(ExePath+'Refresh.bmp');
end;
TNavButton(Controls[i]).Glyph := tempGlyph;
end;
end;
end;
finally
tempGlyph.Free;
end;
end;
| |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|