| Flash for .NET Task-Based Help > C1FlashCanvas Tasks > Drawing Text in C1FlashCanvas > Aligning Text in the Center |
To draw text in the center, complete the following tasks:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Imports C1.C1Flash
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim font As New Font("Courier New", 14)
Dim rect As New Rectangle(35, 170, 160, 35)
Dim sf As New StringFormat(StringFormat.GenericDefault)
rect.Offset(rect.Width + 30, 0)
Me.C1FlashCanvas1.DrawRectangle(Pens.Black, rect)
sf.Alignment = System.Drawing.StringAlignment.Center
Me.C1FlashCanvas1.DrawString("Center alignment", font, Brushes.DarkOrange, rect, sf)
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
using C1.C1Flash;
private void Form1_Load(object sender, System.EventArgs e)
{
Font font = new Font("MS Sans Serif", 14);
Rectangle rect = new Rectangle(35, 170, 160, 35);
StringFormat sf = new StringFormat(StringFormat.GenericDefault);
rect.Offset(rect.Width + 30, 0);
this.c1FlashCanvas1.DrawRectangle(Pens.Black, rect);
sf.Alignment = System.Drawing.StringAlignment.Center;
this.c1FlashCanvas1.DrawString("Center alignment", font, Brushes.DarkOrange, rect, sf);
}
|
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.C1FlashCanvas1.RenderToFile("c:\WindowsApplication1.swf")
LaunchViewer("c:\WindowsApplication1.swf")
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.c1FlashCanvas1.RenderToFile(@"c:\WindowsApplication1.swf"); LaunchViewer(@"c:\WindowsApplication1.swf"); |
|
Here is what your text will look like in Internet Explorer:
