Vb.net[2008] A more efficent way to access MDIChild control?

R

Rob W

Greetings,

I have used the code below to access the ONLY control on the MDIChild a
textbox and if the selected text is not nothing then use the clipboard cut
method.

Could this be done more efficiently?
I was attempting to reference the MDIChild control by its name but could
only find success with the method below.

Dim TB = CType(Me.ActiveMdiChild.ActiveControl, TextBox)
If (TB.SelectedText) IsNot Nothing Then

TB.Cut()

End If


Thanks
Rob
 
R

Rob W

I discovered a method which allows me to reference by MDIChild forms control
name.

Just need to work out where to dimension OpenDocument so I don't have to
declare it for every single operation.



Dim openDocument As document = CType(Me.ActiveMdiChild, document)

If (openDocument.txtEditor.SelectedText) isn't Nothing Then

openDocument.txtEditor.Cut()

End If
 
J

joecool1969

Greetings,

I have used the code below to access the ONLY control on the MDIChild a
textbox and if the selected text is not nothing then use the clipboard cut
method.

Could this be done more efficiently?
I was attempting to reference the MDIChild control by its name but could
only find success with the method below.

Dim TB = CType(Me.ActiveMdiChild.ActiveControl, TextBox)
If (TB.SelectedText) IsNot Nothing Then

TB.Cut()

End If

Controls are defined as Private. A quick and easy way to access a
control with VB woulb be to define a Public property to expose the
control.

Public Property txtEditor_control() As TextBox
Get
Return txtEditor
End Get
Set(ByVal value As TextBox)
txtEditor = value
End Set
End Property
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top