how to dynamically position form inside MDI form?

G

Guest

Greetings.

I have a child form inside an MID parent form. The child form is wider than
the MID parent form. The child form contains a number of textboxes which
are positioned from left to right on the child form where the textbox on the
right is not viewable because it extends beyond the right border of the MDI
parent form. What I need to happen is when I tab through the textboxes -
when I tab into the textbox on the right side of the chld form - the textbox
which is not viewable - I want to bring that textbox into view by
repositioning the child form within the MDI parent form - the same as if I
were to manually scroll the MDI parent form to view the textbox on the right
side of the child form. But I need this to happen dynamically.

Could someone suggest how this could be accomplished? Is there a Move
command for repositioning the child form within the MID parent?

Thanks,
Rich
 
G

Guest

Well, I tried getting the location of the child form by
Console.Writeline(Me.Location.X.ToString + " " + Me.Location.Y.ToString)
when I enter the textbox which I scroll to the right to reach. Then I add
these values to the Offset property of Me.Location.

Private Sub txt3_Enter(...) Handles txt3.Enter
Console.WriteLine(Me.Location.X.ToString & " " & Me.Location.Y.ToString)
Me.Location.Offset(-304, 0)
Console.WriteLine(Me.Location.X.ToString & " " & Me.Location.Y.ToString)
End Sub

I got 0, 0 before the Offset and 0, 0 after the Offset. If I manually
scroll the child form over to the right then I get -304, 0 for Me.Location.

How can I make the form move dynamically to that location?
 
G

Guest

OK. Here is something else I tried that sort of did work:

Private sub txt3_Enter(...)
Dim p As New Point
p.X = -300
p.Y = 0
Me.Location = p
End Sub.

Now the form did move.
 

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