Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2005

Tip: Looking for answers? Try searching our database.

mdi client problems - second try

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tsiGeorge - 31 Dec 2004 05:15 GMT
In our app (VB) client forms are displayed based on what is on the current
client form and the button pressed. A user never selects a client form. You
can think of this process as filling out a very long form with many branches
(e.g., IRS form 1040). Once a client form is loaded it is never unloaded -
just hidden.

I need help resolving these 2 problems:

1) Focus on a text box. I know i can't set the focus in the Load event but
the Activated event only fires when the first client loads. Also, when the
form is redisplayed (i.e., made visible) txtbox.focus, for example, doesn't
work. What I do now is start a timer with a 10ms interval and set the focus
in the timer event. I also think that sometimes when I leave the text box the
Leave event doesn't always fire. There's got to be a better way.

2) Client form size. I would like the client form to be the maximum size
that will fit in the MDI parent. The minimum size of the client forms is set
to 720 X 540. If i set the WindowState to Maximized the first client is
displayed maximized but all the others are displayed at their minimum size.
When the first client form is redisplayed it is also displayed at the minimum
size. This just drives the users crazy. What I've done is after showing the
form the first time or making the form visible on redisplays I set the
child.Dock = DockStyle.Fill. I also do this if the
parent is resized. Now the client is almost maximum size except it still has
its own margins.
Signature

tsiGeorge

Robby - 01 Jan 2005 09:21 GMT
For the first problem.  What could be happening is that the MDI child does
not have focus when it is made visible. After you set Form.Visible = True
call Form.Activate.  This will set the form as the active MDI child and give
it focus.  Then your call to TextBox.Focus will set the focus to the control
as required.

For the second problem.  One solution is to reset the minimum size of the
MDI children to the MDI parent's ClientSize each time the MDI parent is
resized.  This will dynamically resize the MDI children along with the
parent as needed.

Hope this helps.

Robby

> In our app (VB) client forms are displayed based on what is on the current
> client form and the button pressed. A user never selects a client form.
[quoted text clipped - 31 lines]
> has
> its own margins.
tsiGeorge - 01 Jan 2005 23:47 GMT
Problem 1.  I've tried form.Activate. Here is what happens: Activated fires;
the txtBox.focus is executed; Entered fires and I set the backcolor to blue
and the forecolor to white; Leave fires and I set the colors back to
white/black. If I put a break point at the txtBox.focus command and step it
thru the focus is in txtBox with colors set blue/white (but wait the Leave
fired and the colors should be white/black). If I remove the breakpoint the
focus is not in the txtBox and the colors are white/black. There seems to be
a problem with one window becoming invisible and another becoming visible.
Maybe my 10ms timer lets things settle down. Any other suggestions?

Problem 2.

Tried your suggestions. Not any better than child.Dock = DockStyle.Fill and
doesn't position the window correctly (you still need to dock it or
something) and is still not maximized. Is there anyway of "clicking" the
restore box by code?

> For the first problem.  What could be happening is that the MDI child does
> not have focus when it is made visible. After you set Form.Visible = True
[quoted text clipped - 46 lines]
> > has
> > its own margins.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.