Knowledge Base 
Adding buttons to the NavigationPane at run time 
 Thursday, October 29, 2020

Adding buttons to the NavigationPane at run time

You can add buttons to the NavigationPane at run time by using the CreateButton method of the NavigationPane object.

This sample code illustrates how to add new button at run time:

loButton = ThisForm.NavigationPane.CreateButton()
loButton.Caption = "Sample Button"
loButton.Image.Picture = "Image24x24.bmp"
loButton.ImageSmall.Picture = "Image16x16.bmp"
loButton.Visible = .T.
...
... set other properties here
...
ThisForm.NavigationPane.AddButton( m.loButton)
Or, the same result you can achieve by passing values for the Caption, Image and ImageSmall properties to the CreateButton method:

loButton = ThisForm.NavigationPane.CreateButton( ;
               "Sample Button", ;         && Caption
               "Image24x24.bmp", ;        && Image
               "Image16x16.bmp", ;        && ImageSmall
               .T.)                       && call AddButton method