Link to home
Start Free TrialLog in
Avatar of DrDamnit
DrDamnitFlag for United States of America

asked on

How do I use a RichTextBox

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 (http://rdsrc.us/pWeOTh).

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?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Add it to a container.  =)

The Form:

    Me.Controls.Add(x)

A Panel:

    Panel1.Controls.Add(x)

Etc....
*Set a Location if desired:

    x.Location = New Point(25, 50)
Avatar of DrDamnit

ASKER

Idle_Mind:

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
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!  =\
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?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Stupid spell check.