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

  • Thread starter Thread starter Rob W
  • Start date Start date
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
 
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
 
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
 
Back
Top