How do I use a RichTextBox

Posted on 2011-09-10
Last Modified: 2013-11-08
The easy one to use is the one that works right out of the box: System.Windows.Forms.RichTextBox. The one I need to use is System.Windows.Controls.RichTextBox.

I have a System.Windows.Forms.RichTextBox in my program, but need to convert it to a System.Windows.Controls.RichTextBox because it has the ability to do spell check (

I have all the references, and I can create the RichTextBox, but I cannot figure out how to actually get it on the form.

Dim x As New RichTextBox
        x.SpellCheck.IsEnabled = True
        x.Width = 200
        x.Height = 200
        x.Visibility = Visibility.Visible

Open in new window

How do I get this new RTB on the form so I can use it?
Question by:DrDamnit
  • 4
  • 3
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36516383
Add it to a container.  =)

The Form:


A Panel:


LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36516384
*Set a Location if desired:

    x.Location = New Point(25, 50)
LVL 32

Author Comment

ID: 36516418

Tried me.controls.add(), it is the wrong type:
Error      1      Value of type 'System.Windows.Controls.RichTextBox' cannot be converted to 'System.Windows.Forms.Control'.      C:\Users\michael\Documents\Visual Studio 2010\Projects\ComposerPad\ComposerPad\Form1.vb      112      25      ComposerPad

lcoation doesn't work either:
Error      1      'location' is not a member of 'System.Windows.Controls.RichTextBox'.      C:\Users\michael\Documents\Visual Studio 2010\Projects\ComposerPad\ComposerPad\Form1.vb      112      9      ComposerPad
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36516434
Ah!...sorry.  I wasn't paying attention very closely.

The System.Windows.Controls.RichTextBox is a WPF control.  It can't be used in a WinForms app.  If you really need that control then build a WPF application.

*WinForms and WPF applications are completely different beasts!  =\
LVL 32

Author Comment

ID: 36516455
Oh crap.

Does that mean I have to RE-BUILD the ENTIRE application as a WPF application?

Can I copy / paste the controls from one to the other?

Is this a major undertaking?
LVL 85

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 36516469
Major would be an understatement...

WPF applications use a completely different architecture and paradigm than a WinForms application!

I don't know if this is worth the effort:

LVL 32

Author Comment

ID: 36516511
Stupid spell check.

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Assigning handler to UserControls in flowlayoutpanel 4 23 Move a class from Solution Items to a project 2 23
SqlServer no dupes 25 35
C# LINQ ForEach() question 6 28
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question