• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

How do I add a return carriage to a WPF ElementHost in a Windows Form?

I needed to add spell check to a windows form textbox so I used the add a WPF Interoperability, ElementHost option.  I added this code.

Dim CommentHost = New System.Windows.Controls.TextBox()
        CommentHost.SpellCheck.IsEnabled = True
        CommentHost.VerticalScrollBarVisibility = ScrollBarVisibility.Visible
        CommentHost.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible
        CommentHost.TextWrapping = TextWrapping.Wrap

        Me.hostBox.Child = CommentHost

I have everything working very nice - saving to tables, loading edit screens until I hit the return key to add another line...  Doh, nothing happens!  

Any suggestions?  My users add several "one-liners" to their activity report and this is a must-have.

Karen Wilson
Karen Wilson
1 Solution
Michael FowlerSolutions ConsultantCommented:
Try setting AcceptsReturn to true

CommentHost.AcceptsReturn = True

Open in new window


Karen WilsonAuthor Commented:
Worked like a charm.  Thanks for the link as well.  Exactly what I need!!  

Have a great evening....
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now