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

Cant select text in Textbox on a Form which is a control

I have a problem I cannot figure out.
Im unable to use the mouse to select text or position the cursor within a textbox on forms, which are assigned to the control collection of another form.
The code Im using to open & display the form is as follows.

        Dim frmFieldEditor As New frmFieldEditor()

        frmFieldEditor.TopLevel = False
        frmFieldEditor.fldText = e.TextField
        Me.Controls.Add(frmFieldEditor)
        frmFieldEditor.Show()
        frmFieldEditor.BringToFront()

The form operates just fine, except the textboxes on the fieldeditor form will not allow me to use the mouse to manipulate the text.

Thanks.
0
Jimby_Aus
Asked:
Jimby_Aus
  • 3
  • 2
1 Solution
 
RonaldBiemansCommented:
have you setting the textbox.enabled = true
0
 
Jimby_AusAuthor Commented:
yes textbox is enabled.
I can type in the textbox OK, I just cant use the mouse to change the cursor position or select text.

0
 
RonaldBiemansCommented:
Is there a reason to add the form to the controls of the calling form, it seems very strange to do this (this is what causes the problem)
0
 
Jimby_AusAuthor Commented:
Yes, because I want to keep the form in the boundaries of its parent form, without using MDI.
MDI will not work for this, because I have a control that fills the entire parent form, and MDI child windows would appear behind it, which no good.
0
 
RonaldBiemansCommented:
Well for as far as I now, you are out of luck because the mousecursor is always relative to the owner form in this case your main form hence it is unable to paint and place the cursor correctly. You can test this by adding a mousedown event to your textbox like

    Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
        TextBox1.Cursor.Position = New Point(e.X, e.Y)
    End Sub

you will see that the mouse pointer will jump to your mainform
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

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