RichTextBox control WPF in VB.NET

Here we will see that how to use RichTextBox control.
  • 1272
Download Files:

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.



XAML code

<Window x:Class="MainWindow"



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


        <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 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 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" />



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






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



Now select the text and apply Bold on the text.



Similarly, we can test for Italic and underline text.


More Articles

© 2013 dotNetheaven. All rights reserved.