|
-
Jun 27th, 2008, 08:06 AM
#1
Thread Starter
New Member
[RESOLVED] passing information between forms
What I want to do Is when I click on a listbox filled with childIDs.
I want the child form if it is open to show the detail Record.
I can get the id from the list.
#Region "Events"
Friend Event ShowDetailRecord(ByVal orderDetail As bsOrderDetail)
#End Region
Private Sub lst_RecordDetail_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lst_RecordDetail.SelectedIndexChanged
Dim orderDetail As bsOrderDetail = CType(lst_RecordDetail.Items(lst_RecordDetail.SelectedIndex), bsOrderDetail)
RaiseEvent ShowDetailRecord(orderDetail)
End Sub
But how would I pass it off to another form?
frm_Detail doesn't know about frm_Master or should I pass a reference to a child when I create the master form?
-
Jun 27th, 2008, 08:14 AM
#2
Re: passing information between forms
Do you show the detailform modal/Dialog?
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Jun 27th, 2008, 08:44 AM
#3
Re: passing information between forms
Do you already has form2 opened when you select an item from form1.listbox?
Do you want to re-use the instance of form2 or do you want to show a new instance of form2 for each different record?
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jun 27th, 2008, 09:20 AM
#4
Thread Starter
New Member
Re: passing information between forms
Do you show the detailform modal/Dialog?
No normal form
Do you already have form2 opened when you select an item from form1.listbox?
Do you want to re-use the instance of form2 or do you want to show a new instance of form2 for each different record?
I already created a form, so I want to reuse the detail form.
I have a main form that has references to all child forms.
Private frmFactuur As Form
Private frmOrder As Form
Private frmOrderDetail As Form
Private frmOver As Form
So the frmOrder sends an event with the orderDetail ID that needs to be displayed in frmOrderDetail.
but how do I get a reference to it.
Nevermind I got it, I had to change
Private frmOrder As Form to Private withevents frmOrder As frm_Order
then get the id and ask the detail form to show it.
Last edited by Stef569; Jun 27th, 2008 at 09:33 AM.
-
Jun 27th, 2008, 10:59 AM
#5
Re: passing information between forms
maybe you should look at addhandler and removehandler instead to do the job.
On showing a detailform add a handler (addhandler ...)
On closing the Detail form you could fire an event to pas the detailsObject to any reciever.
These recievers can process the detail object and remove the handler
On closing the "parent Form" the handler can be remoed as well.
Why this concept?
More control over the procces and less handlerers in case your detail form has multiple events.
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Jun 27th, 2008, 01:31 PM
#6
Re: passing information between forms
This link is to a thread that has several suggestions as to how to pass data between forms:
http://www.vbforums.com/showthread.p...ght=definitive
My usual boring signature: Nothing
 
-
Jun 27th, 2008, 05:45 PM
#7
Thread Starter
New Member
Re: passing information between forms
in reply to Hiker
You could add this response to
3)Passing data from Parent form to Child form in an MDI environment
http://www.vbforums.com/showpost.php...6&postcount=17
it seems to be a good way.
Dnereb
I have a simple program, don't want to change handlers at runtime.
I don't understand why i Would use it anyway :/
I always want the detailRecord event to be fired, a function that performs an action when the event is fired need to be typed.
So
"More control over the process and less handlers in case your detail form has multiple events."
By the first part you mean that I can stop handling events?
the second part I don't understand, you have to type the function. how can there be less handlers?
Last edited by Stef569; Jun 27th, 2008 at 05:55 PM.
-
Jun 28th, 2008, 03:14 AM
#8
Re: passing information between forms
Although I do not see why you won't want to change handlers at runtime, that's entirely up to you. I can not make your designtime/optimization descisions.
And Yes you can stop handling events, that is a handler you,ve added with addhandler can be removed with remove handler.
Keep in mind that an event is slightly diffrent to a call to a sub or function.
Dim Withevents X as SomeObject
Results in Illcode written to create delegates, four delegates for each event to be catched.
The 'problem' is:
an event fired but the reciever has been disposed. in C# you need to write code to prevent this or accept a crash. You can imagine this results in a lot of illcode to handle all possible situations behind the scenes in VB.NET.
Using addhandler creates less Illcode and remove handler ensures that code isn't executed anymore.
The code in your handling sub/function should be roughly the same in dynamic handling or using withevents anyway.
I prefer to do these handlings myself, mainly because it keeps me aware of the actual code an application flow, not the optimization, optimization becomes an issue if your app encourages to have dozens of detail forms open all firing multiple events that can effect other detail forms.
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
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
|
Click Here to Expand Forum to Full Width
|