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 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);
}
}
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;
}
}
}
}
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 cmbFonts_SelectedIndexChanged(ByVal sender As Object, ByVal e As _
System.EventArgs)Handles cmbFonts.SelectedIndexChanged
If cmbFonts.Text <> "" Then
setFont()
End If
End Sub
//C#
private void cmbFonts_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(cmbFonts.Text != "")
setFont();
}
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 cmbFontSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As _
System.EventArgs)Handles cmbFontSize.SelectedIndexChanged
If cmbFontSize.Text <> "" Then
setFont()
End If
End Sub
//C#
private void cmbFontSize_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(cmbFontSize.Text != "")
setFont();
}
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 cmbClassName_SelectedIndexChanged(ByVal sender As Object, ByVal e As _
System.EventArgs)Handles cmbClassName.SelectedIndexChanged
If cmbClassName.Text <> "" Then
setClassName()
End If
End Sub
//C#
private void cmbClassName_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(cmbClassName.Text != "")
setClassName();
}
| See Also |
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.