Klicke hier für den deutschen Artikel.
Problem
There is a requirement to customise the functionality of the toolbar buttons in a List & Label preview according to individual preferences. However, it is not possible to integrate a customised button directly into the preview window.
Solution
Although it is not possible to directly integrate an individual button into the preview, List & Label offers various approaches for integrating your own functions or customising the buttons in the preview as required.
The following approaches refer to the List & Label PreviewControl:
Customising the toolbar
The preview toolbar offers flexible control:
-
Disable the entire toolbar:
LLPreviewControl.ShowToolbar = false;
SettingShowToolbarto false hides the standard toolbar and enables you to provide your own fully customisable toolbar within the application. This enables buttons with individual functions to be added. -
Disable individual buttons:
LLPreviewControl.ToolbarButtons.SendTo = LlButtonState.Disabled; -
Hide individual buttons:
LLPreviewControl.ToolbarButtons.SaveAs = LlButtonState.Invisible;
Responding to the ButtonPress event
When a button in PreviewControl is clicked, List & Label triggers the ButtonPress event. This event can be intercepted in the code to implement your own functions. The event arguments provide information about the button that was clicked. This enables you to identify specific clicks and perform custom actions, such as exporting to ZUGFeRD directly from the preview:
// ButtonPress-Event
LLPreviewControl.ButtonPress += (sender, e) =>
{
if (e.ButtonID == 112)
{
if (!File.Exists($"{previewFile}"))
CreatePRVFile();
PreviewFile prv = new PreviewFile($"{previewFile}");
prv.ConvertTo($@"{exportPath}", "PDF;PDF.ZUGFeRDVersion=2.0;"
+ "PDF.ZUGFeRDXmlPath=" + zugFerdXMLpath);
if (LLPreviewControl.CanClose())
this.Close();
}
};
The individual ButtonIDs can be found in the MenuID.txt file in the Documentation subdirectory of the List & Label installation directory.
Conclusion
It is not possible to extend the preview directly with your own buttons. However, you can adapt the preview flexibly to your requirements using the ButtonPress events. You can do this by deactivating specific toolbar elements or by integrating a separate toolbar.