ARTICLE

WPF RichTextBox control in VB.NET

Posted by Rohatash Kumar Articles | XAML in VB.NET March 15, 2011
Here we will see that how to use RichTextBox control.
Download Files:
 
Reader Level:

Here we will see that how to use RichTextBox control.

RichTextBox control

The RichTextBox control that supports rich formatting, automatic line wrapping, HTML and RTF import/export, table support, images and more.

For example

Drag and drop three TextBlock,three Button control on the form.

The window form looks like this.

r1.gif

Figure1.gif

XAML code

<Window x:Class="MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="MainWindow" Height="350" Width="525">

    <Grid>

        <Canvas x:Name="LayoutRoot" Background="White">

            <StackPanel Orientation="Horizontal" Canvas.Left="0" Canvas.Top="20" Height="30" Width="184">

            <Button x:Name="makeBold" Width="47" Height="23"  Margin="10, 2, 2, 2" ToolTipService.ToolTip="Bold">

            <TextBlock x:Name="boldText" Text="B" FontFamily="Arial" FontSize="14" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" />

                </Button>

                <Button x:Name="makeItalic" Width="55" Height="23" Margin="2" ToolTipService.ToolTip="Italic">

                <TextBlock x:Name="italicText" Text="I" FontFamily="Arial" FontSize="14" FontStyle="Italic" HorizontalAlignment="Center" VerticalAlignment="Center" />

                </Button>

                <Button x:Name="makeUnderline" Width="56" Height="20" Margin="2" ToolTipService.ToolTip="Underline">

                <TextBlock x:Name="underlineText" Text="U" FontFamily="Arial" FontSize="14" TextDecorations="Underline" HorizontalAlignment="Center" VerticalAlignment="Center" />

            </Button>  

            </StackPanel>

            <RichTextBox Height="136" Name="RichTextBox2" Width="289" Canvas.Left="20" Canvas.Top="69" >

            </RichTextBox>

        </Canvas>

</Grid>

</Window>

 

Now run the application and enter the text into RichTextBox control.

r2.gif

Figure2.gif

Now select the text and apply Bold on the text.

r3.gif

Figure3.gif

Similarly, we can test for Italic and underline text.

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Nevron Diagram
Become a Sponsor