By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

Cross form communication...

P: n/a
Using VS2005, VB.NET, I have am developing a windows app that has a
login form. This login form can be called by several classes. When the
login form is able to verify that the supplied credentials are valid
then I want to pass an object (System.Net.Credential) back to the
calling/parent class. All the classes that call the login form have a
public property named "_oCredentials" that could be used to store
validated credentials.

My problem is knowing what class opened/called the login form and
getting the code in the form to store the validated credentials back
in the correct parent...

Hope this makes sense. Your input appreciated.

FYI, here is how I am calling the form now (from any of the "parent"
classes)
'Gather domain credentials
Dim frmLogin As New frmDomainLogin
frmLogin.ShowDialog(Me)

Oct 10 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Oct 10, 9:56 am, hzgt9b <celof...@gmail.comwrote:
Using VS2005, VB.NET, I have am developing a windows app that has a
login form. This login form can be called by several classes. When the
login form is able to verify that the supplied credentials are valid
then I want to pass an object (System.Net.Credential) back to the
calling/parent class. All the classes that call the login form have a
public property named "_oCredentials" that could be used to store
validated credentials.

My problem is knowing what class opened/called the login form and
getting the code in the form to store the validated credentials back
in the correct parent...

Hope this makes sense. Your input appreciated.

FYI, here is how I am calling the form now (from any of the "parent"
classes)
'Gather domain credentials
Dim frmLogin As New frmDomainLogin
frmLogin.ShowDialog(Me)
You could create a interface for all your parent forms to implement.
Call it something like iCallTheLoginForm or whatever is appropriate.
Then in your login form you can reference the parent form by casting
it to your interface.

Public Interface iCallTheLoginForm
Public Property LoginCredential as System.Net.Credential
End Interface

Public Class MainForm
implements iCallTheLoginForm

Public Property MainForm_LoginCredential As System.Net.Credential
Implements iCallTheLoginForm.LoginCredential

.....

Public Class LoginForm

Private myParent as iCallTheLoginForm

Public Sub New(p as iCallTheLoginForm)
myParent = p
End Sub

.....
That should be a good start, I quick typed that one, so it might have
a typo...

Oct 10 '07 #2

P: n/a
You could create a interface for all your parent forms to implement.
Call it something like iCallTheLoginForm or whatever is appropriate.
Then in your login form you can reference the parent form by casting
it to your interface.

Public Interface iCallTheLoginForm
Public Property LoginCredential as System.Net.Credential
End Interface
Thanks for the quick response... unfortunately I am unable to declare
a property of type "System.Net.Credential" as the return type in the
interface (even after importing System.Net)...

Oct 10 '07 #3

P: n/a
what i usually do in this situation, is overload the ShowDialog function wiht
my own return type, then do the base form's showdialog then return the
info....ex

Public Overloads Function ShowDialog() As String

MyBase.ShowDialog()

Return String.Empty

End Function

and there ya go. hope this helps
--
-iwdu15
Oct 10 '07 #4

P: n/a
Thanks, I implemented an interface and then did the case back to the
form... works great.

Oct 12 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.