Version

Process ToolClick Events

This topic demonstrates how to process ToolClick events for a tool on an MDI child form. Even though an MDI child form’s toolbars and tools can be set to merge into the MDI parent form’s toolbars, the ToolClick events for tools that originated from the child will be fired on the MDI child UltraToolBarsManager. This is advantageous since it allows you to encapsulate all processing for child tools directly on the child form. This sample can be followed to see this behavior.

  1. Set the IsMdiContainer property of your parent form to True.

  2. Add an MDI child form called ProcessingToolClickChildForm to your project.

  3. Add the UltraToolBarsManager to each of these forms.

  4. Add some tools to the UltraToolBarsManager of the MDI parent and the MDI child form.

  5. Add the following code to show the MDI child form in the MDI parent.

In Visual Basic:

Private Sub Process_ToolClick_Events_Load(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles MyBase.Load
	Dim frm As New ProcessingToolClickChildForm()
	frm.MdiParent = Me
	frm.Show()
End Sub

In C#:

private void Process_ToolClick_Events_Load(
  object sender, EventArgs e)
{
	ProcessingToolClickChildForm frm = new ProcessingToolClickChildForm();
	frm.MdiParent = this;
	frm.Show();
}
  1. Add a ToolClick event handler to the MDI child’s UltraToolBarsManager.

For example, the following code sets text to a TextBox that is on ProcessingToolClickChildForm when a button tool is clicked. The button has already been added to Toolbar in the design-time customizer.

In Visual Basic:

Private Sub UltraToolbarsManager1_ToolClick(ByVal sender As Object, _
  ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) _
  Handles UltraToolbarsManager1.ToolClick
	If e.Tool.Key = "Infragistics" Then
		TextBox1.Text = "Infragistics"
	End If
End Sub

In C#:

private void ultraToolbarsManager1_ToolClick(object sender,
  Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
	if(e.Tool.Key == "Infragistics")
		textBox1.Text = "Infragistics";
}