UD Form- Quick Print Preview Button

Dear experts, How to add custom QuickPrintPreview button in standard tool bar using UD01 form?

Step 1

using Infragistics.Win.UltraWinToolbars;

Step 2

	private void UD01Form_Load(object sender, EventArgs args)
	{
		ButtonTool btnPrintTool = new ButtonTool("MyPrintTool");
	    //Set the properties
	    btnPrintTool.SharedProps.Caption = "Print List";
	    btnPrintTool.SharedProps.Enabled = true;
	    btnPrintTool.SharedProps.Visible = true;
	    btnPrintTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("Print")];
		btnPrintTool.ToolClick += new ToolClickEventHandler(btnPrintTool_ToolClick);
	    baseToolbarsManager.Tools.Add(btnPrintTool);
	    baseToolbarsManager.Toolbars["Standard Tools"].Tools.AddTool("MyPrintTool");
	}

	private void btnPrintTool_ToolClick(object sender,ToolClickEventArgs args)
	{		
		EpiMessageBox.Show("Printed Successfully");
	}
3 Likes

The UD Form actually comes with the regular Print Tool, it doesnt do anything but you can make it visible and then use it.

// Enable the Print Tool
baseToolbarsManager.Tools["PrintTool"].SharedProps.Enabled = true;
baseToolbarsManager.Tools["PrintTool"].SharedProps.Visible = true;

Then just use the event

private void UD100Form_BeforeToolClick(object sender, Ice.Lib.Framework.BeforeToolClickEventArgs args)
{
	switch (args.Tool.Key)
	{
		case "PrintTool":

			if (edvUD100A.dataView.Count == 0) {
				args.Handled = true;
			}

			break;

	}
}

Thats another option. I do appreciate @surendrapal solution. Good timing as I just needed to add a new button to the Standard Tools :slight_smile:

4 Likes

Also just for the sake of snippets… You can also add a Dropdown to the Standard Tools and some other stuff.

private void SetupToolbarItems()
{
	// Get The Main Toolbar
	UltraToolbar mainToolBar = this.baseToolbarsManager.Toolbars["Standard Tools"];

	// Remove the Single NewTool Button from the Toolbar Root
	mainToolBar.Tools.Remove(mainToolBar.Tools["NewTool"]);

	// Make Epicors Popup Tool NewMenuTool Visibile (most forms have this hidden by default)
	baseToolbarsManager.Tools["NewMenuTool"].SharedProps.Visible = true;

	// Hide the Save Button since we will not allow Saving
	baseToolbarsManager.Tools["SaveTool"].SharedProps.Visible = false;

	// Hide the Delete Tool since will not allow Deleting
	baseToolbarsManager.Tools["DeleteTool"].SharedProps.Visible = false;

	// Hide the Search Tool since we will not allow Searching
	baseToolbarsManager.Tools["SearchTool"].SharedProps.Visible = false;

	// Make others Visible or Invisible
	baseToolbarsManager.Tools["PrintTool"].SharedProps.Visible = true;

	// Remove these Items from the Toolbar but not from the Actions Menu
	string[] arMainTools = new string[6] {"CutTool", "RefreshTool", "CopyTool", "PasteTool", "UndoTool", "AttachmentTool"};
	foreach (string tool in arMainTools)
	{
		mainToolBar.Tools.Remove(mainToolBar.Tools[ tool ]);
	}


	// WIP: Skids
	Infragistics.Win.UltraWinToolbars.ComboBoxTool comboSkidCountTool	= new Infragistics.Win.UltraWinToolbars.ComboBoxTool("SkidCount");
	Infragistics.Win.UltraWinToolbars.LabelTool skidToolLbl = new Infragistics.Win.UltraWinToolbars.LabelTool("SkidCountLabel");

	skidToolLbl.SharedProps.Caption	= "Skids: ";
	skidToolLbl.SharedProps.AppearancesSmall.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
	skidToolLbl.SharedProps.MinWidth = 50;
	skidToolLbl.SharedProps.Width = 50;
	skidToolLbl.SharedProps.MaxWidth = 50;

	// Show 32 Skids
	for (int i = 1; i < 33; i++)
	{
		comboSkidCountTool.ValueList.ValueListItems.Add( i );
	}

	comboSkidCountTool.SharedProps.MinWidth = 40;
	comboSkidCountTool.SharedProps.Width = 40;
	comboSkidCountTool.SharedProps.MaxWidth = 40;
	comboSkidCountTool.SharedProps.AppearancesSmall.Appearance.TextHAlign = Infragistics.Win.HAlign.Left;
	comboSkidCountTool.SharedProps.Caption = "Skids:";
	comboSkidCountTool.SelectedIndex = 1;
	comboSkidCountTool.DropDownStyle = Infragistics.Win.DropDownStyle.DropDownList;
	//comboSkidCountTool.Value			= "<Select a comnposer>";
	comboSkidCountTool.SharedProps.ToolTipText	= "How Many Skids Do You Need?";
	comboSkidCountTool.AutoComplete		= true;
	comboSkidCountTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("Material")];

	//
	// Modify the Existing NewTool
	//
	baseToolbarsManager.Tools["NewTool"].SharedProps.Caption = "New Design";

	//
	// Create a Add Label Button
	//
	Infragistics.Win.UltraWinToolbars.ButtonTool NewLabelToolItem = new Infragistics.Win.UltraWinToolbars.ButtonTool("NewLabel");
	NewLabelToolItem.SharedProps.Caption = "Add Label";
	NewLabelToolItem.SharedProps.Enabled = true;
	NewLabelToolItem.SharedProps.Visible = true;
	NewLabelToolItem.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("Material")];

	//
	// Create a Print Button
	//
	Infragistics.Win.UltraWinToolbars.ButtonTool PrintToolItem = new Infragistics.Win.UltraWinToolbars.ButtonTool("PrintTool2");
	PrintToolItem.SharedProps.Caption = "Print Labels";
	PrintToolItem.SharedProps.Enabled = true;
	PrintToolItem.SharedProps.Visible = false;
	PrintToolItem.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("Print")];

	// Register our Buttons with the Base Toolbars Manager
	//baseToolbarsManager.Tools.Add(NewLabelToolItem);
	baseToolbarsManager.Tools.Add(PrintToolItem);
	baseToolbarsManager.Tools.Add(skidToolLbl);
	baseToolbarsManager.Tools.Add(comboSkidCountTool);

	// Add the NewLabel Button also to the Root Toolbar
	//baseToolbarsManager.Toolbars["Standard Tools"].Tools.AddTool("NewLabel");
	mainToolBar.Tools.AddTool("SkidCountLabel");
	mainToolBar.Tools.AddTool("SkidCount");

	// Add the Buttons to our Popup (DropDown) New Button Group
	((Infragistics.Win.UltraWinToolbars.PopupMenuTool)baseToolbarsManager.Tools["NewMenuTool"]).Tools.AddTool("NewTool");
	//((Infragistics.Win.UltraWinToolbars.PopupMenuTool)baseToolbarsManager.Tools["NewMenuTool"]).Tools.AddTool("NewLabel");
	((Infragistics.Win.UltraWinToolbars.PopupMenuTool)baseToolbarsManager.Tools["NewMenuTool"]).Tools.AddTool("SkidCount");
}

For the dropdown you can use ToolValueChanged

private void UD08Form_ToolValueChanged(object sender, Infragistics.Win.UltraWinToolbars.ToolEventArgs args)
{
	string sSkids = ((Infragistics.Win.UltraWinToolbars.ComboBoxTool)(args.Tool)).Text;
}

You can see the dropdown in this vid

4 Likes