Glossary Item Box
This walkthrough is split up into the following activities:
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub selChangeLayoutToolbar()
cnt = Me.Designer1.Selection.Count
If cnt = 0 Then
Me.setModes(toolbarModes.noControls)
ElseIf ((cnt = 1) AndAlso ((Me.Designer1.Selection(0).GetType().BaseType.ToString() _
<> "DataDynamics.ActiveReports.Section") AndAlso _
(Me.Designer1.Selection(0).GetType().BaseType.ToString()<> "System.Object"))) Then
Me.setModes(toolbarModes.singleControl)
ElseIf (cnt = 2) Then
Me.setModes(toolbarModes.twoControls)
ElseIf (cnt > 2) Then
Me.setModes(toolbarModes.multiControls)
End If
End Sub
//C#
private void selChangeLayoutToolbar()
{
int cnt = this.designer1.Selection.Count;
if(cnt==0)
{
this.setModes(toolbarModes.noControls);
}
else if((cnt==1)&&((this.designer1.Selection[0].GetType().BaseType.ToString() !=
"DataDynamics.ActiveReports.Section")&&(this.designer1.Selection[0]_
GetType().BaseType.ToString() != "System.Object")))
{
this.setModes(toolbarModes.singleControl);
}
else if(cnt==2)
{
this.setModes(toolbarModes.twoControls);
}
else if(cnt >2)
{
this.setModes(toolbarModes.multiControls);
}
}
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub setModes(ByVal tbModes As Form1.toolbarModes)
Me.SuspendLayout()
Select Case tbModes
Case toolbarModes.multiControls
Me.tbbAlignBottoms.Enabled = True
Me.tbbAlignCenters.Enabled = True
Me.tbbAlignLefts.Enabled = True
Me.tbbAlignMiddles.Enabled = True
Me.tbbAlignRights.Enabled = True
Me.tbbAligntoGrid.Enabled = True
Me.tbbAlignTops.Enabled = True
Me.tbbBringToFront.Enabled = True
Me.tbbCenterHoriz.Enabled = True
Me.tbbCenterVert.Enabled = True
Me.tbbDecreaseHorizSpace.Enabled = True
Me.tbbDecreaseVertSpace.Enabled = True
Me.tbbIncreaseHorizSpace.Enabled = True
Me.tbbIncreaseVertSpace.Enabled = True
Me.tbbMakeHorizSpaceEqual.Enabled = True
Me.tbbMakeSameHeight.Enabled = True
Me.tbbMakeSameSize.Enabled = True
Me.tbbMakeSameWidth.Enabled = True
Me.tbbMakeVertSpaceEqual.Enabled = True
Me.tbbRemoveHorizSpace.Enabled = True
Me.tbbRemoveVertSpace.Enabled = True
Me.tbbSendToBack.Enabled = True
Me.tbbSizeToGrid.Enabled = True
Case toolbarModes.twoControls
Me.tbbAlignBottoms.Enabled = True
Me.tbbAlignCenters.Enabled = True
Me.tbbAlignLefts.Enabled = True
Me.tbbAlignMiddles.Enabled = True
Me.tbbAlignRights.Enabled = True
Me.tbbAligntoGrid.Enabled = True
Me.tbbAlignTops.Enabled = True
Me.tbbBringToFront.Enabled = True
Me.tbbCenterHoriz.Enabled = True
Me.tbbCenterVert.Enabled = True
Me.tbbDecreaseHorizSpace.Enabled = False
Me.tbbDecreaseVertSpace.Enabled = False
Me.tbbIncreaseHorizSpace.Enabled = False
Me.tbbIncreaseVertSpace.Enabled = False
Me.tbbMakeHorizSpaceEqual.Enabled = False
Me.tbbMakeSameHeight.Enabled = True
Me.tbbMakeSameWidth.Enabled = True
Me.tbbMakeSameSize.Enabled = True
Me.tbbMakeVertSpaceEqual.Enabled = False
Me.tbbRemoveHorizSpace.Enabled = True
Me.tbbRemoveVertSpace.Enabled = True
Me.tbbSendToBack.Enabled = True
Me.tbbSizeToGrid.Enabled = True
Case toolbarModes.singleControl
Me.tbbAlignBottoms.Enabled = False
Me.tbbAlignCenters.Enabled = False
Me.tbbAlignLefts.Enabled = False
Me.tbbAlignMiddles.Enabled = False
Me.tbbAlignRights.Enabled = False
Me.tbbAligntoGrid.Enabled = True
Me.tbbAlignTops.Enabled = False
Me.tbbCenterHoriz.Enabled = True
Me.tbbCenterVert.Enabled = True
Me.tbbDecreaseVertSpace.Enabled = False
Me.tbbIncreaseVertSpace.Enabled = False
Me.tbbDecreaseHorizSpace.Enabled = False
Me.tbbIncreaseHorizSpace.Enabled = False
Me.tbbMakeHorizSpaceEqual.Enabled = False
Me.tbbMakeSameHeight.Enabled = False
Me.tbbMakeSameSize.Enabled = False
Me.tbbMakeSameWidth.Enabled = False
Me.tbbMakeVertSpaceEqual.Enabled = False
Me.tbbRemoveHorizSpace.Enabled = False
Me.tbbRemoveVertSpace.Enabled = False
Me.tbbSendToBack.Enabled = True
Me.tbbSizeToGrid.Enabled = True
Me.tbbBringToFront.Enabled = True
Case toolbarModes.noControls
Me.tbbAlignBottoms.Enabled = False
Me.tbbAlignCenters.Enabled = False
Me.tbbAlignLefts.Enabled = False
Me.tbbAlignMiddles.Enabled = False
Me.tbbAlignRights.Enabled = False
Me.tbbAligntoGrid.Enabled = False
Me.tbbAlignTops.Enabled = False
Me.tbbBringToFront.Enabled = False
Me.tbbCenterHoriz.Enabled = False
Me.tbbCenterVert.Enabled = False
Me.tbbDecreaseHorizSpace.Enabled = False
Me.tbbDecreaseVertSpace.Enabled = False
Me.tbbIncreaseHorizSpace.Enabled = False
Me.tbbIncreaseVertSpace.Enabled = False
Me.tbbMakeHorizSpaceEqual.Enabled = False
Me.tbbMakeSameHeight.Enabled = False
Me.tbbMakeSameSize.Enabled = False
Me.tbbMakeSameWidth.Enabled = False
Me.tbbMakeVertSpaceEqual.Enabled = False
Me.tbbRemoveHorizSpace.Enabled = False
Me.tbbRemoveVertSpace.Enabled = False
Me.tbbSendToBack.Enabled = False
Me.tbbSizeToGrid.Enabled = False
End Select
Me.ResumeLayout()
End Sub
//C#
private void setModes(frmDesigner.toolbarModes tbModes)
{
this.SuspendLayout();
switch(tbModes)
{
case toolbarModes.multiControls:
this.tbbAlignBottoms.Enabled =true;
this.tbbAlignCenters.Enabled = true;
this.tbbAlignLefts.Enabled = true;
this.tbbAlignMiddles.Enabled = true;
this.tbbAlignRights.Enabled = true;
this.tbbAlignToGrid.Enabled = true;
this.tbbAlignTops.Enabled = true;
this.tbbBringToFront.Enabled = true;
this.tbbCenterHoriz.Enabled = true;
this.tbbCenterVert.Enabled = true;
this.tbbDecreaseHorizSpace.Enabled = true;
this.tbbDecreaseVertSpace.Enabled = true;
this.tbbIncreaseHorizSpace.Enabled = true;
this.tbbIncreaseVertSpace.Enabled = true;
this.tbbMakeHorizSpaceEqual.Enabled = true;
this.tbbMakeSameHeight.Enabled = true;
this.tbbMakeSameSize.Enabled = true;
this.tbbMakeSameWidth.Enabled = true;
this.tbbMakeVertSpaceEqual.Enabled = true;
this.tbbRemoveHorizSpace.Enabled = true;
this.tbbRemoveVertSpace.Enabled = true;
this.tbbSendToBack.Enabled = true;
this.tbbSizeToGrid.Enabled = true;
break;
case toolbarModes.twoControls:
this.tbbAlignBottoms.Enabled =true;
this.tbbAlignCenters.Enabled = true;
this.tbbAlignLefts.Enabled = true;
this.tbbAlignMiddles.Enabled = true;
this.tbbAlignRights.Enabled = true;
this.tbbAlignToGrid.Enabled = true;
this.tbbAlignTops.Enabled = true;
this.tbbBringToFront.Enabled = true;
this.tbbCenterHoriz.Enabled = true;
this.tbbCenterVert.Enabled = true;
this.tbbDecreaseHorizSpace.Enabled = false;
this.tbbDecreaseVertSpace.Enabled = false;
this.tbbIncreaseHorizSpace.Enabled = false;
this.tbbIncreaseVertSpace.Enabled = false;
this.tbbMakeHorizSpaceEqual.Enabled = false;
this.tbbMakeSameHeight.Enabled = true;
this.tbbMakeSameSize.Enabled = true;
this.tbbMakeSameWidth.Enabled = true;
this.tbbMakeVertSpaceEqual.Enabled = false;
this.tbbRemoveHorizSpace.Enabled = true;
this.tbbRemoveVertSpace.Enabled = true;
this.tbbSendToBack.Enabled = true;
this.tbbSizeToGrid.Enabled = true;
break;
case toolbarModes.singleControl:
this.tbbAlignBottoms.Enabled =false;
this.tbbAlignCenters.Enabled = false;
this.tbbAlignLefts.Enabled = false;
this.tbbAlignMiddles.Enabled = false;
this.tbbAlignRights.Enabled = false;
this.tbbAlignToGrid.Enabled = true;
this.tbbAlignTops.Enabled = false;
this.tbbBringToFront.Enabled = true;
this.tbbCenterHoriz.Enabled = true;
this.tbbCenterVert.Enabled = true;
this.tbbDecreaseHorizSpace.Enabled = false;
this.tbbDecreaseVertSpace.Enabled = false;
this.tbbIncreaseHorizSpace.Enabled = false;
this.tbbIncreaseVertSpace.Enabled = false;
this.tbbMakeHorizSpaceEqual.Enabled = false;
this.tbbMakeSameHeight.Enabled = false;
this.tbbMakeSameSize.Enabled = false;
this.tbbMakeSameWidth.Enabled = false;
this.tbbMakeVertSpaceEqual.Enabled = false;
this.tbbRemoveHorizSpace.Enabled = false;
this.tbbRemoveVertSpace.Enabled = false;
this.tbbSendToBack.Enabled = true;
this.tbbSizeToGrid.Enabled = true;
break;
case toolbarModes.noControls:
this.tbbAlignBottoms.Enabled =false;
this.tbbAlignCenters.Enabled = false;
this.tbbAlignLefts.Enabled = false;
this.tbbAlignMiddles.Enabled = false;
this.tbbAlignRights.Enabled = false;
this.tbbAlignToGrid.Enabled = false;
this.tbbAlignTops.Enabled = false;
this.tbbBringToFront.Enabled = false;
this.tbbCenterHoriz.Enabled = false;
this.tbbCenterVert.Enabled = false;
this.tbbDecreaseHorizSpace.Enabled = false;
this.tbbDecreaseVertSpace.Enabled = false;
this.tbbIncreaseHorizSpace.Enabled = false;
this.tbbIncreaseVertSpace.Enabled = false;
this.tbbMakeHorizSpaceEqual.Enabled = false;
this.tbbMakeSameHeight.Enabled = false;
this.tbbMakeSameSize.Enabled = false;
this.tbbMakeSameWidth.Enabled = false;
this.tbbMakeVertSpaceEqual.Enabled = false;
this.tbbRemoveHorizSpace.Enabled = false;
this.tbbRemoveVertSpace.Enabled = false;
this.tbbSendToBack.Enabled = false;
this.tbbSizeToGrid.Enabled = false;
break;
}
this.ResumeLayout();
}
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub executeLayoutAction(ByVal actionTool As String)
Select Case actionTool
Case "BringToFront"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatOrderBringToFront)
Case "SendToBack"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatOrderSendToBack)
Case "MakeSameHeight"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSizeSameHeight)
Case "MakeSameWidth"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSizeSameWidth)
Case "MakeSameSize"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSizeBoth)
Case "AlignTops"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatAlignTop)
Case "AlignBottoms"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatAlignBottom)
Case "AlignLefts"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatAlignLeft)
Case "AlignRights"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatAlignRight)
Case "AlignMiddles"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatAlignMiddle)
Case "AlignCenters"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatAlignCenter)
Case "SizeToGrid"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.SnapToGrid)
Case "MakeHorizSpaceEqual"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSpaceEquallyHorizontal)
Case "IncreaseHorizSpace"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSpaceIncreaseHorizontal)
Case "DecreaseHorizSpace"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSpaceDecreaseHorizontal)
Case "MakeVertSpaceEqual"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSpaceEquallyVertical)
Case "IncreaseVertSpace"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSpaceIncreaseVertical)
Case "DecreaseVertSpace"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSpaceDecreaseVertical)
Case "CenterHoriz"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatCenterHorizontally)
Case "CenterVert"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatCenterVertically)
Case "RemoveHorizSpace"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSpaceRemoveHorizontal)
Case "RemoveVertSpace"
Me.Designer1.ExecuteAction(DataDynamics.ActiveReports.Design._
DesignerAction.FormatSpaceRemoveVertical)
End Select
End Sub
//C#
private void executeLayoutAction(string actionTool)
{
switch(actionTool)
{
case "BringToFront":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatOrderBringToFront);
break;
case "SendToBack":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatOrderSendToBack);
break;
case "MakeSameHeight":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSizeSameHeight);
break;
case "MakeSameWidth":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSizeSameWidth);
break;
case "MakeSameSize":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSizeBoth);
break;
case "AlignTops":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatAlignTop);
break;
case "AlignBottoms":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatAlignBottom);
break;
case "AlignLefts":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatAlignLeft);
break;
case "AlignRights":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatAlignRight);
break;
case "AlignMiddles":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatAlignMiddle);
break;
case "AlignCenters":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatAlignCenter);
break;
case "SizeToGrid":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.SnapToGrid);
break;
case "MakeHorizSpaceEqual":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSpaceEquallyHorizontal);
break;
case "IncreaseHorizSpace":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSpaceIncreaseHorizontal);
break;
case "DecreaseHorizSpace":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSpaceDecreaseHorizontal);
break;
case "MakeVertSpaceEqual":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSpaceEquallyVertical);
break;
case "IncreaseVertSpace":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSpaceIncreaseVertical);
break;
case "DecreaseVertSpace":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSpaceDecreaseVertical);
break;
case "CenterHoriz":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatCenterHorizontally);
break;
case "CenterVert":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatCenterVertically);
break;
case "RemoveHorizSpace":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSpaceRemoveHorizontal);
break;
case "RemoveVertSpace":
this.designer1.ExecuteAction(DataDynamics.ActiveReports.Design.
DesignerAction.FormatSpaceRemoveVertical);
break;
}
}
To write the code in Visual Basic
To write the code in C#
The following example shows what the code for the method looks like.
' Visual Basic
Private Sub tlbLayout_ButtonClick(ByVal sender As Object, ByVal e As _
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tlbLayout.ButtonClick
Me.executeLayoutAction(e.Button.Tag.ToString())
End Sub
//C#
private void tlbLayout_ButtonClick(object sender, System.Windows.Forms.
ToolBarButtonClickEventArgs e)
{
this.executeLayoutAction(e.Button.Tag.ToString());
}
See Also |
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.