Change glyphs of the TBDNavigator's buttons  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 18/02/00

Tip accessed 540 times

 


In this example, we will copy the Glyph of a SpeedButton (SpeedButton1) in the button ' Prior' of the Navigator. It is only an example. In fact it would not be necessary to use a SpeedButton, we could make everything by means of code, but for the example it is more comfortable.

  • Put a TDBNavigator (DBNavigator1) and a SpeedButton (SpeedButton1) in your form
  • Load a Glyph in the SpeedButton1
  • Put this code in the OnCreate of the form:


     procedure TForm1.FormCreate(Sender: TObject);
     var
       c: Integer;
     begin
       with DBNavigator1 do
       begin
         for c := 0 to ControlCount -1 do
           if Controls[c] is TNavButton then
             with TNavButton(Controls[c]) do
             begin
               case Index of
                 nbPrior: Glyph := SpeedButton1.Glyph;
               end;
             end;
       end;
     end;
    




    Without a SpeedButton:

     procedure TForm1.Button1Click(Sender: TObject);
     var
       c       : Integer;
       tempBMP : tBitmap;
     begin
       tempBMP:=TBitmap.Create;
       try
         TempBMP.LoadFromFile('c:\kk\kk.bmp');
         with DBNavigator1 do
         begin
           for c := 0 to ControlCount -1 do
             if Controls[c] is TNavButton then
               with TNavButton(Controls[c]) do
               begin
                 case Index of
                   nbPrior: Glyph := TempBMP;
                 end;
               end;
         end;
       finally
         TempBMP.Free;
       end;
     end;