Glossary Item Box

Samples | Walkthroughs

See Also ActiveReports for .NET 2 Online Help Send feedback to Data Dynamics

Walkthrough: Adding Code for the Combo Boxes

This walkthrough is split up into the following activities:

Adding code for the ComboBox operations events

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 fillFonts()
Me.cmbFonts.Items.Clear()
Dim fc As New System.Drawing.Text.InstalledFontCollection()
For i = 0 To fc.Families.Length - 1
Me.cmbFonts.Items.Add(fc.Families(i).Name)
Next
Me.cmbFonts.SelectedIndex = 0End SubPrivate Sub fillFontSizes()
cmbFontSize.Items.Clear()
cmbFontSize.Items.Add(" 8")
cmbFontSize.Items.Add(" 9")
cmbFontSize.Items.Add("10")
cmbFontSize.Items.Add("11")
cmbFontSize.Items.Add("12")
cmbFontSize.Items.Add("14")
cmbFontSize.Items.Add("16")
cmbFontSize.Items.Add("18")
cmbFontSize.Items.Add("20")
cmbFontSize.Items.Add("22")
cmbFontSize.Items.Add("24")
cmbFontSize.Items.Add("26")
cmbFontSize.Items.Add("28")
cmbFontSize.Items.Add("36")
cmbFontSize.Items.Add("48")
cmbFontSize.Items.Add("72")
Me.cmbFontSize.SelectedIndex = 0
End Sub
Private Sub fillClassName()
Me.cmbClassName.Items.Clear()
For i = 0 To Designer1.Report.StyleSheet.Count - 1
Me.cmbClassName.Items.Add(Designer1.Report.StyleSheet(i).Name)
Next
Me.cmbClassName.SelectedIndex = 0
End Sub
//C#
private void fillFonts()
{
this.cmbFonts.Items.Clear();
System.Drawing.Text.FontCollection fc = new System.Drawing.Text .InstalledFontCollection();
for(int i=0;i<fc.Families.Length;i++)
{
this.cmbFonts.Items.Add(fc.Families[i].Name);
}
}
private void fillFontSizes()
{
cmbFontSize.Items.Clear();
cmbFontSize.Items.Add(" 8");
cmbFontSize.Items.Add(" 9");
cmbFontSize.Items.Add("10");
cmbFontSize.Items.Add("11");
cmbFontSize.Items.Add("12");
cmbFontSize.Items.Add("14");
cmbFontSize.Items.Add("16");
cmbFontSize.Items.Add("18");
cmbFontSize.Items.Add("20");
cmbFontSize.Items.Add("22");
cmbFontSize.Items.Add("24");
cmbFontSize.Items.Add("26");
cmbFontSize.Items.Add("28");
cmbFontSize.Items.Add("36");
cmbFontSize.Items.Add("48");
cmbFontSize.Items.Add("72");
}
private void fillClassName()
{
this.cmbClassName.Items.Clear();
for(int i=0;i<designer1.Report.StyleSheet.Count;i++)
{
this.cmbClassName.Items.Add(designer1.Report.StyleSheet[i].Name);
}
}

Adding code to adjust text in the ComboBoxes

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 setFont()
	For i = 0 To i < Designer1.Selection.Count - 1
		ctl = Designer1.Selection(i).Get_
                           	Type.ToString()
		If ((ctl.IndexOf("TextBox") > 0) Or (ctl.IndexOf("CheckBox") > 0) Or _
			(ctl.IndexOf("Label") > 0)) Then
			Select Case ctl
                Case "DataDynamics.ActiveReports.TextBox"
                    If cmbFontSize.Text <> "" Then
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.TextBox)_
			Font = New Font(cmbFonts.Text, (Long.Parse(cmbFontSize.Text)))
                    Else
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.TextBox)_
                           	.Font = New Font(cmbFonts.Text, (Long.Parse(Font.Size.ToString)))
                    End If
                Case "DataDynamics.ActiveReports.Label"
                    If cmbFontSize.Text <> "" Then
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.Label) _
                           	.Font = New Font(cmbFonts.Text, (Long.Parse(cmbFontSize.Text)))
                    Else
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.Label).Font _
                           	 = New Font(cmbFonts.Text, (Long.Parse(Font.Size.ToString)))
                    End If
                Case "DataDynamics.ActiveReports.CheckBox"
                    If cmbFontSize.Text <> "" Then
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.CheckBox).Font _
                           	= New Font(cmbFonts.Text, (Long.Parse(cmbFontSize.Text)))
                    Else
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.CheckBox).Font _
                           	= New Font(cmbFonts.Text, (Long.Parse(Font.Size.ToString)))
                    End If
            End Select
            End If
        Next
End Sub
Private Sub setClassName()
        For i = 0 To i < Designer1.Selection.Count - 1
            ctl = Designer1.Selection(i).GetType.ToString()
            If ctl.IndexOf("TextBox") > 0 Or ctl.IndexOf("CheckBox") > 0 Or _
            	 ctl.IndexOf("Label")> 0 Then
                Select Case ctl
                    Case "DataDynamics.ActiveReports.TextBox"
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.TextBox) _
                        	.ClassName = cmbClassName.Text
                    Case "DataDynamics.ActiveReports.Label"
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.Label)_
                        	.ClassName = cmbClassName.Text
                    Case "DataDynamics.ActiveReports.CheckBox"
                        CType(Designer1.Selection(i), DataDynamics.ActiveReports.CheckBox)_
                        	.ClassName = cmbClassName.Text
                End Select
            End If
        Next
End Sub
//C#
private void setFont()
{
	for(int i=0;i<designer1.Selection.Count;i++)
	{
		string ctl = designer1.Selection[i].GetType().ToString();
		if((ctl.IndexOf("TextBox") >0)||(ctl.IndexOf("CheckBox") >0)||(ctl.
			IndexOf("Label") >0))
		{
			switch(ctl)
			{
				case "DataDynamics.ActiveReports.TextBox":
					if(cmbFontSize.Text!="")
					{
						((DataDynamics.ActiveReports.TextBox)
						  designer1.Selection[i]).Font =
 						  new Font(cmbFonts.Text,(float.
						  Parse(cmbFontSize.Text)));
					}
					else
					{
						((DataDynamics.ActiveReports.TextBox)
						  designer1.Selection[i]).Font =
 						  new Font(cmbFonts.Text,float.Parse
						  (((DataDynamics.ActiveReports.TextBox)
						  designer1.Selection[i]).Font.Size.ToString()));
					}
					break;
				case "DataDynamics.ActiveReports.Label":
					if(cmbFontSize.Text!="")
					{
						((DataDynamics.ActiveReports.Label)
						  designer1.Selection[i]).Font =
 						  new Font(cmbFonts.Text,
						  (float.Parse
						  (cmbFontSize.Text)));
					}
					else
					{
						((DataDynamics.ActiveReports.Label)
						  designer1.Selection[i]).Font =
 						  new Font(cmbFonts.Text,
						  float.Parse(((DataDynamics.
						  ActiveReports.Label)
						  designer1.Selection[i]).
						  Font.Size.ToString()));
					}
					break;
				case "DataDynamics.ActiveReprots.CheckBox":
					if(cmbFontSize.Text!="")
					{
						((DataDynamics.ActiveReports.CheckBox)
						  designer1.Selection[i]).Font =
 						  new Font(cmbFonts.Text,
						  (float.Parse(cmbFontSize.Text)));
					}
					else
					{
						((DataDynamics.ActiveReports.CheckBox)
						  designer1.Selection[i]).Font =
 						  new Font(cmbFonts.Text,
						  float.Parse
						  (((DataDynamics.ActiveReports.
						  CheckBox)designer1.
						  Selection[i]).
						  Font.Size.ToString()));
					}
					break;
			}
		}
	}
}
private void setClassName()
{
	for(int i=0;i<designer1.Selection.Count;i++)
	{
		string ctl = designer1.Selection[i].GetType().ToString();
		if((ctl.IndexOf("TextBox") >0)||(ctl.IndexOf("CheckBox")
 			>0)||(ctl.IndexOf("Label") >0))
		{
			switch(ctl)
			{
				case "DataDynamics.ActiveReports.TextBox":
					((DataDynamics.ActiveReports.TextBox)
						designer1.Selection[i]).ClassName =
 						cmbClassName.Text;
					break;
				case "DataDynamics.ActiveReports.Label":
					((DataDynamics.ActiveReports.Label)
						designer1.Selection[i]).ClassName =
 						cmbClassName.Text;
					break;
				case "DataDynamics.ActiveReports.CheckBox":
					((DataDynamics.ActiveReports.CheckBox)
						designer1.Selection[i]).ClassName =
 						cmbClassName.Text;
					break;
			}
		}
	}
}

Adding code for the cmbFonts SelectIndexChanged event

To write the code in Visual Basic

To write the code in C#

Adding code for the cmbFontSize_SelectIndexChanged event

To write the code in Visual Basic

To write the code in C#

Adding code for the cmbClassName_SelectIndexChanged event

To write the code in Visual Basic

To write the code in C#

Samples | Walkthroughs

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.