Title: Changing DbNavigator's Icons
Question: how can I change the icons from a DbNavigator ??
Answer:
First, put a DbNavigator in your form and configure it normally with your data source.
Go in the source code of the form and create a new data type before the class created to the form; like this:
type
NewTypeNav = class( TDbNavigator );
TForm1 = class(TForm);
After this, go to the event OnCreate of this form and put the following code:
var
c:Tbitmap;
begin
c:=Tbitmap.Create;
c.LoadFromFile('C:\Insert.bmp');
newtypenav(dbnavigator1).buttons[nbinsert].Glyph:=c;
In this case, just the icon of the button Insert will be changed. To change all buttons, repeat theses 3 lines changing the bitmap name and the button's variables.
Here is the Variables:
NbFirst - Button First
NbPrior - Button Prior
NbNext - Button Next
NbLast - Button Last
NbInsert - Button Insert
NbDelete - Button Delete
NbEdit - Button Edit
NbPost - Button Post
NbRefresh - Button Refresh
TIP: This Example show how to load the picture for the button from a Bitmap File, If you whish, you can put a TImage for each image in your form and load the images in project time, reducing the source code for load the images. Replacing that 3 lines for just 1.
newtypenav(DbNavigator).buttons[nbprior].Glyph:=Form1.Imgprior.picture.bitmap;