|
-
May 18th, 2004, 05:56 AM
#1
Thread Starter
Frenzied Member
Modal Form Problem
I have noticed with .NET that when I display a modal form, if a place user input validation code in a click procedure
eg. MsgBox("Please enter a valid number.")
Text1.Focus()
Exit Sub
that after exiting sub the form is minimised. Has anyone else encoutered this frustrating behaviour? I can't see any obvious reason why this is happening. The form's default window state is set to normal.
-
May 18th, 2004, 07:35 AM
#2
PowerPoster
Hi,
It appears that this behaviour is dependent of your selection of the Startup Position property. Th effect you describe only happens if you set it to Windows Default.
What puzzles me is:
1. When the form is minimised as you describe, what is the untitled empty form left in view?
2. The behaviour you describe is negated if you add a button to the form and use that to activate the validation event.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
May 18th, 2004, 08:58 AM
#3
Thread Starter
Frenzied Member
I tried running the program from the exe (ie.not from the .NET IDE) and discovered that the form only minimises when there is a maximised window of another application in the background. However, if there is no maximised window, although the form does not minimise, the focus is not set to the text box.
I tried all of the startup position options and the validate event without success.
-
May 18th, 2004, 09:26 AM
#4
PowerPoster
Hi,
I did not try it with other applications running, so that accounts for the difference in the results observed.
Could we see your actual code please?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
May 18th, 2004, 09:32 AM
#5
Thread Starter
Frenzied Member
VB Code:
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
If IsNumeric(Text1.Text) = False Then
MsgBox("Please enter a valid number.")
Text1.Focus()
Exit Sub
else
'etc etc
End If
End Sub
-
May 18th, 2004, 09:42 AM
#6
PowerPoster
Hi,
Thanks.
Yes, that ties up with my experience that when you use a button event, the form (assuming there is no other application running) behaves properly.
If you carried out the validation in the Text_Changed event of the text box, the form would minimise regardless of other applications.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
May 18th, 2004, 06:59 PM
#7
Thread Starter
Frenzied Member
When there are no applications running, it still does not behave as I would expect. The form is not minimised but the text box does not take the focus as it should with Text1.Focus()
You have to click in the text box to give it the focus.
Is this a .NET bug? VB6 certainly doesn't behave this way.
-
May 18th, 2004, 07:49 PM
#8
PowerPoster
Hi,
On rechecking the behaviour, the form is NOT minimised. It is mostly hiding behind a new blank, untitled form!!!!
However, if you then click the form it stays in view whenever you nextcarry out the validation.
Wierd!!
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
May 19th, 2004, 02:32 AM
#9
Thread Starter
Frenzied Member
I solved the problem by setting the FormBorderStyle property to Sizable.
The problem occurs when this property is set to FixedToolWindow.
-
May 19th, 2004, 04:57 AM
#10
PowerPoster
Hi,
"I solved the problem by setting the FormBorderStyle property to Sizable.
The problem occurs when this property is set to FixedToolWindow."
That does not work for me. Were you getting the "Ghost" form as I posted?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|