Skip to main content Skip to footer

How to add custom button to C1PrintPreviewControl

Following are the steps to add a custom button in the C1PrintPreviewControl toolbar at design time :

  • Drag and drop the C1PrintPreviewControl on the form:

  • Open the Properties window of the control.

  • Toolbars || File (or navigation, page etc) || ToolStrip || Items.

  • Click on the collection tab against the 'Items'

  • 'ItemsCollectionEditor' dialog will pop-up and you will get options to add buttons, separators, etc.

  • Select the control from the left pane and set the properties in the right pane.

  • Click OK and the 'ToolStripButton' will be added in the toolbarstrip.

  • Click on the newly added button and open it's properties window. Select the event's tab and double click on the 'Click' option.

  • The method to handle the click event of the new toostrip button will be created in the code.

Add the following code in the Form_Load event to add a custom button at run time:

'Create a new instance of ToolStripButton</p>  
Dim button As New ToolStripButton  
'Customize the button properties  
button.Text = "CustomButton_ViaCode"  
button.Image = ""  
'Add  this button in the PrintPreviewControl under any of the group (file in this case)  
C1PrintPreviewControl1.ToolBars.File.ToolStrip.Items.Add(Button)  
'Create click event handler of the button  
AddHandler button.Click, AddressOf button_click

Using the above steps, this is how the custom buttons (added via code and added via designer) would look like in the C1PrintPreviewControl.

Print Preview Control with Custom Button