-
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
-
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
>
>
-
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
>>
>>
>
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks