TX Text Control comes with pre-configured dialog boxes to select and insert local images into a document. This article shows how to implement an extension method to use a custom dialog to insert images.
The following extension adds a method CustomDialog to the Image
╰ TXTextControl Namespace
╰ ImageCollection Class
An instance of the ImageCollection class contains all images in a Text Control document or part of the document represented through objects of the type Image. .
This method accepts 3 parameters:
|Parameter||Value Type||Value description|
|preferredFormat||String||The preferred format that should be pre-selected. Sample: "*.png".|
|showAll||bool||Specifies whether an additional "All Supported Formats" option should be added to the list.|
|openFileDialog||OpenFileDialog||An OpenFileDialog object that can be pre-configured for additional customization.|
Extension Method Usage
The following code opens a custom dialog with the preferred format PNG and without the All Supported Formats option:
The following call opens the dialog with the All Supported Formats option:
If you want to change the title, the default directory and other options, you can pass a pre-configured OpenFileDialog to the CustomDialog method: