How do I validate an elementhost in a windows form application

I need to validate that there is a information in an elementhost that I have put in a windows form application.

I can see what I want when I drill down inside the child and go to text but I can't point to it in this code.  Here is the code I am using.  

Any suggestions would be much appreciated!!

Thanks.


  ElseIf control.GetType.ToString = "System.Windows.Forms.Integration.ElementHost" Then
            Dim thisString As System.Windows.Forms.Integration.ElementHost = CType(control, Integration.ElementHost)
            If thisString.Child Is "" Then
                MessageBox.Show(thisString.Tag.ToString & " is a required field.", Title)
                thisString.Select()
                Return False
            Else
                Return True
            End If
Karen WilsonProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Karen WilsonProgrammerAuthor Commented:
Figured it out....  I've also included all the code I use when playing with a WPF elementhost in a windows form application.  The result of this question is at the bottom.

Imports System.Windows
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Forms.Integration


Dim CommentHost = New System.Windows.Controls.TextBox()

CommentHost.SpellCheck.IsEnabled = True
CommentHost.VerticalScrollBarVisibility = ScrollBarVisibility.Visible
CommentHost.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible
CommentHost.TextWrapping = TextWrapping.Wrap
CommentHost.AcceptsReturn = True

Me.hostBox.Child = CommentHost

or if the box is going to contain a string you use this:

Dim narrativeString As String = "Overview of Waste Generation:"

CommentHost.Text = narrativeString
Me.hostBox.Child = CommentHost


To save it to your table:

tblA.Comment = CStr(Me.CommentHost.Text)

Put it in an edit form:
 Me.CommentHost.Text = CStr(tblA.Comment)

To validate:
ElseIf control.GetType.ToString = "System.Windows.Forms.Integration.ElementHost" Then
            Dim thisString As Integration.ElementHost = CType(control, Integration.ElementHost)
            Dim textStuff As System.Windows.Controls.TextBox = CType(thisString.Child, System.Windows.Controls.TextBox)
            If textStuff.Text Is "" Then
                MessageBox.Show(thisString.Tag.ToString & " is a required field.", Title)
                thisString.Select()
                Return False
            Else
                Return True
            End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.