Cross form communication...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hzgt9b

    Cross form communication...

    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.Cre dential) back to the
    calling/parent class. All the classes that call the login form have a
    public property named "_oCredenti als" 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.ShowDi alog(Me)

  • Charlie Brown

    #2
    Re: Cross form communication.. .

    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.Cre dential) back to the
    calling/parent class. All the classes that call the login form have a
    public property named "_oCredenti als" 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.ShowDi alog(Me)
    You could create a interface for all your parent forms to implement.
    Call it something like iCallTheLoginFo rm or whatever is appropriate.
    Then in your login form you can reference the parent form by casting
    it to your interface.

    Public Interface iCallTheLoginFo rm
    Public Property LoginCredential as System.Net.Cred ential
    End Interface

    Public Class MainForm
    implements iCallTheLoginFo rm

    Public Property MainForm_LoginC redential As System.Net.Cred ential
    Implements iCallTheLoginFo rm.LoginCredent ial

    .....

    Public Class LoginForm

    Private myParent as iCallTheLoginFo rm

    Public Sub New(p as iCallTheLoginFo rm)
    myParent = p
    End Sub

    .....


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

    Comment

    • hzgt9b

      #3
      Re: Cross form communication.. .

      You could create a interface for all your parent forms to implement.
      Call it something like iCallTheLoginFo rm or whatever is appropriate.
      Then in your login form you can reference the parent form by casting
      it to your interface.
      >
      Public Interface iCallTheLoginFo rm
      Public Property LoginCredential as System.Net.Cred ential
      End Interface
      >
      Thanks for the quick response... unfortunately I am unable to declare
      a property of type "System.Net.Cre dential" as the return type in the
      interface (even after importing System.Net)...

      Comment

      • =?Utf-8?B?aXdkdTE1?=

        #4
        RE: Cross form communication.. .

        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.ShowDial og()

        Return String.Empty

        End Function

        and there ya go. hope this helps
        --
        -iwdu15

        Comment

        • hzgt9b

          #5
          Re: Cross form communication.. .

          Thanks, I implemented an interface and then did the case back to the
          form... works great.

          Comment

          Working...