Re: Open child form from dialog form



Well. I still have one little problem.
If user press OK button, but username or password is invalid, how can I
found out that login failed in sub main?

Thanks for your time!

Simon





"Armin Zingler" <az.nospam@xxxxxxxxxx> wrote in message
news:u8oRcJtWFHA.2128@xxxxxxxxxxxxxxxxxxxxxxx
> "Simon Abolnar" <Simon.Abolnar@xxxxxxxxx> schrieb
>> 1. Thank you very much for your suggestion.
>> I tried to aplied your solution.
>> It works OK, except I can't close login dialog.
>> When I press OK button, application (MDI form) run, with dialog form
>> still present.
>> I don't know where to close dialog form. in sub main or in btnOK
>> event and how?
>>
>> I changed your solution to:
>>
>> Shared Sub main()
>> Dim loginform As New frmPrijava
>>
>> loginform.btnOK.DialogResult = loginform.DialogResult.OK
>>
>> If loginform.ShowDialog = loginform.DialogResult.OK Then
>>
>> Application.Run(New frmReferatNET)
>>
>> End If
>>
>> End Sub
>
>
> The code looks ok. I can not reproduce the problem. When I click the
> button,
> the loginform disappears and the MDI form is shown. Setting the button's
> dialogresult property should be sufficient to close the modal form when
> the
> button is clicked. From here I can't see what causes this behavior. Try to
> call Me.Close explicitly in the button's click event.
>
>> 2. Despite, I still don't know why you want to open an MDI child
>> form from the
>> login form. Is the child form always to be displayed at startup
>> or does it
>> depend on any selection within the login form?
>>
>> Yes, I would like to display MDI child form after successfull login.
>> It depends on user.
>
>
> There are some design questions involved. The solution I'd probably choose
> is this one:
>
> Public Class App
>
> Private Shared f_Username As String
>
> Public Shared ReadOnly Property Username() As String
> Get
> Return f_Username
> End Get
> End Property
>
> Shared Sub main()
>
> Dim LoginForm As New LoginForm
>
> If LoginForm.ShowDialog = DialogResult.OK Then
> f_Username = LoginForm.txtUsername.Text
> LoginForm.Dispose()
> LoginForm = Nothing
>
> Application.Run(New MDIForm)
> End If
>
> End Sub
>
> End Class
>
>
> I've set the button's dialogresult property in the designer.
>
>
>
> MDIForm:
>
> Private Sub MDIForm_Load( _
> ByVal sender As System.Object, ByVal e As System.EventArgs) _
> Handles MyBase.Load
>
> Select Case App.Username
> '.... open child
> End Select
>
> End Sub
>
>
> Armin
>


.