navigating between forms


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: navigating between forms

  1. #1
    Lata Ravi Guest

    navigating between forms


    When moving from from a to form b is there a way to refresh the form b with
    the details used in form a.

    I am trying to create a form1. This form has a button which takes me to form
    2. Upon selecting items from a list box in form2, is there way to refresh
    form1 withose selected from form2?

    TIA
    Lata

  2. #2
    Lata Ravi Guest

    Re: navigating between forms


    Thanks for the response. But I am trying to load a datagrid in form1 depending
    upon the selected items of form2. This I am doing in the form load of form1.
    But the form load is not responding that way

    "Phil Weber" <pweber @ fawcette.com> wrote:
    > > I am trying to create a form1. This form has a button which takes
    > > me to form2. Upon selecting items from a list box in form2, is there
    > > way to refresh form1 with those selected from form2?

    >
    >Lata: The easy way is to simply read the selected items directly out of

    the
    >listbox on form2:
    >
    > ' -- in form1
    >
    > ' show form2
    > form2.Show vbModal
    >
    > ' when form2 is closed, read selected items
    > ' out of form2.lstBox
    > With form2.lstBox
    > For I = 0 To .ListCount - 1
    > If .Selected(I) Then
    > Debug.Print .List(I)
    > End If
    > Next
    > End With
    >
    >A better way, in my opinion, is to create a property in form2 (e.g.,
    >"SelectedItems") that returns an array or collection of the selected items.
    >When control returns to form1, it can retrieve the value of form2's
    >..SelectedItems property.
    >
    >This is better because now form1 doesn't have to know anything about the
    >implementation of form2 (such as that there's a listbox named lstBox
    >containing the items), it simply knows that form2 returns a list of items.
    >You can change the implementation of form2 without breaking the associated
    >code in form1.
    >---
    >Phil Weber
    >
    >



  3. #3
    Shrikant Joshi Guest

    Re: navigating between forms


    Hi Lata,

    At the form load, the controls are not yet loaded. So the form_load event
    doesnot understand/know control properties.

    So use form activate event instead form load.

    Shrikant


    "Lata Ravi" <lravi@as-one.net> wrote:
    >
    >Thanks for the response. But I am trying to load a datagrid in form1 depending
    >upon the selected items of form2. This I am doing in the form load of form1.
    >But the form load is not responding that way
    >
    >"Phil Weber" <pweber @ fawcette.com> wrote:
    >> > I am trying to create a form1. This form has a button which takes
    >> > me to form2. Upon selecting items from a list box in form2, is there
    >> > way to refresh form1 with those selected from form2?

    >>
    >>Lata: The easy way is to simply read the selected items directly out of

    >the
    >>listbox on form2:
    >>
    >> ' -- in form1
    >>
    >> ' show form2
    >> form2.Show vbModal
    >>
    >> ' when form2 is closed, read selected items
    >> ' out of form2.lstBox
    >> With form2.lstBox
    >> For I = 0 To .ListCount - 1
    >> If .Selected(I) Then
    >> Debug.Print .List(I)
    >> End If
    >> Next
    >> End With
    >>
    >>A better way, in my opinion, is to create a property in form2 (e.g.,
    >>"SelectedItems") that returns an array or collection of the selected items.
    >>When control returns to form1, it can retrieve the value of form2's
    >>..SelectedItems property.
    >>
    >>This is better because now form1 doesn't have to know anything about the
    >>implementation of form2 (such as that there's a listbox named lstBox
    >>containing the items), it simply knows that form2 returns a list of items.
    >>You can change the implementation of form2 without breaking the associated
    >>code in form1.
    >>---
    >>Phil Weber
    >>
    >>

    >



  4. #4
    Phil Weber Guest

    Re: navigating between forms

    > I am trying to create a form1. This form has a button which takes
    > me to form2. Upon selecting items from a list box in form2, is there
    > way to refresh form1 with those selected from form2?


    Lata: The easy way is to simply read the selected items directly out of the
    listbox on form2:

    ' -- in form1

    ' show form2
    form2.Show vbModal

    ' when form2 is closed, read selected items
    ' out of form2.lstBox
    With form2.lstBox
    For I = 0 To .ListCount - 1
    If .Selected(I) Then
    Debug.Print .List(I)
    End If
    Next
    End With

    A better way, in my opinion, is to create a property in form2 (e.g.,
    "SelectedItems") that returns an array or collection of the selected items.
    When control returns to form1, it can retrieve the value of form2's
    ..SelectedItems property.

    This is better because now form1 doesn't have to know anything about the
    implementation of form2 (such as that there's a listbox named lstBox
    containing the items), it simply knows that form2 returns a list of items.
    You can change the implementation of form2 without breaking the associated
    code in form1.
    ---
    Phil Weber



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center