DelphiFAQ Home Search:

Changing the TDBNavigator button images

 

commentsThis 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 { ChangeDBNavImage }
  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; { case TNavButton(Controls[i]).index }

          TNavButton(Controls[i]).Glyph := tempGlyph; // <--  Assign the loaded bitmap

        end; { Controls[i].ClassName='TNavButton' }
      end; { for i }
    end; { with DBnav }

  finally
    tempGlyph.Free;
  end; { try }
end; { ChangeDBNavImage }
You don't like the formatting? Check out SourceCoder then!

Comments:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Washington, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.