Quick Print Preview Button

I have done this on a few forms. I chose to use the buttons to set a checkbox which then does the print processing via Data Directive BPM as this seemed much easier. There are two buttons added to my form, print preview and send document. I removed the existing print button because I wanted to have better control over exactly how and where the printing took place. The result looks like
image

In addition to the below and the BPMs, you will need to add and remove the events below in the relevant InitializeCustomCode and DestroyCustomCode:
Script.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(Script.baseToolbarsManager_ToolClick);
Script.SalesOrderForm.Shown += new System.EventHandler(Script.SalesOrderForm_Shown);

private static void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
{
	try
	{
		if(args.Tool.Key=="PrintPreview")
		{
			EpiDataView edvOrderHead = (EpiDataView)oTrans.EpiDataViews["OrderHed"];
			edvOrderHead.dataView[0].BeginEdit();
			edvOrderHead.CurrentDataRow["Checkbox04"] = true;
			edvOrderHead.dataView[0].EndEdit(); 
			oTrans.Update(); 
		}
		if(args.Tool.Key=="SendDocument")
		{
			EpiDataView edvOrderHead = (EpiDataView)oTrans.EpiDataViews["OrderHed"];
			edvOrderHead.dataView[0].BeginEdit();
			edvOrderHead.CurrentDataRow["Checkbox05"] = true;
			edvOrderHead.dataView[0].EndEdit(); 
			oTrans.Update(); 
		}
	}
	catch
	{
	}

	}


private static void SalesOrderForm_Shown(object sender, EventArgs args)
{
	//create new buttons for print preview and send document
	Infragistics.Win.UltraWinToolbars.ButtonTool PPTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("PrintPreview");
	Infragistics.Win.UltraWinToolbars.ButtonTool SDTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("SendDocument");
	// set the Properties of the new buttons
	PPTool.SharedProps.Caption = "Print Preview";
	PPTool.SharedProps.Enabled = true;
	PPTool.SharedProps.Visible = true;
	SDTool.SharedProps.Caption = "Send Document";
	SDTool.SharedProps.Enabled = true;
	SDTool.SharedProps.Visible = true;
	PPTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("PrintPreview")];		
	SDTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("SendRecByEmail")];		
	//Add the buttons to the tool bar at the index position		
	baseToolbarsManager.Tools.Add(PPTool);
	baseToolbarsManager.Toolbars["Standard Tools"].Tools.InsertTool(14, "PrintPreview");
	baseToolbarsManager.Tools.Add(SDTool);
	baseToolbarsManager.Toolbars["Standard Tools"].Tools.InsertTool(15, "SendDocument");

	baseToolbarsManager.Toolbars["Standard Tools"].Tools["PrintPreview"].InstanceProps.IsFirstInGroup=true;
	baseToolbarsManager.Toolbars["Standard Tools"].Tools["PrintTool"].SharedProps.Visible = false;

	foreach (Infragistics.Win.UltraWinToolbars.ToolBase Tool in Script.baseToolbarsManager.Toolbars["Standard Tools"].Tools)
	{

		if(Tool.Key=="PrintTool")
		{
			
			//Tool.SharedProps.Visible = false;
		}
	}

}


public static void AddButtons()
{


	//create a new button tool for UltraWinToolbars
	 Infragistics.Win.UltraWinToolbars.ButtonTool PPTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("PrintPreview");
	 Infragistics.Win.UltraWinToolbars.ButtonTool SDTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("SendDocument");
	// set the Properties of the new menu
	       PPTool.SharedProps.Caption = "Print Preview";
	       PPTool.SharedProps.Enabled = true;
	       PPTool.SharedProps.Visible = true;
	       SDTool.SharedProps.Caption = "Send Document";
	       SDTool.SharedProps.Enabled = true;
	       SDTool.SharedProps.Visible = true;

			PPTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("PrintPreview")];		
			baseToolbarsManager.Tools.Add(PPTool);
			baseToolbarsManager.Toolbars["Standard Tools"].Tools.InsertTool(14, "PrintPreview");
			SDTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("SendRecByEmail")];		
			baseToolbarsManager.Tools.Add(SDTool);
			baseToolbarsManager.Toolbars["Standard Tools"].Tools.InsertTool(15, "SendDocument");


}

Good Luck!

3 Likes