I am Korean.
Writes through Google Translator.
The program I'm writing is tcp communication.
I opened "B Form" in "A Form".
("A Form" -> "B Form")
I want to send and receive commands from "B Form" but I do not know what to do.
This is the current way.
1. In "A form", click button and wait.
2. Client requests are processed according to the request value.
(There is a separate class file for waiting and processing the request.)
DO NOT DEAL WITH THIS MEMBER
Depending on what you want to update this can be done in multiple wayse. If you want to for example update a listbox or listview or something on the other form, you can use databinding and pass a reference to a bindinglist to another form. Or you can use custom events. Whatever you want.
I didn't understand it quite well. but seems hard.
..
the a form is just a control panel ? and b form is the one that will send data?
you said you created class, then just create new instance on the b form.
DO NOT DEAL WITH THIS MEMBER
(May 29, 2018 07:46 AM)Esteban Wrote: ..
the a form is just a control panel ? and b form is the one that will send data?
you said you created class, then just create new instance on the b form.
Or pass a reference to the class in the constructor of the B form.
(May 29, 2018 07:48 AM)Dalvik Wrote: Or pass a reference to the class in the constructor of the B form.
..
may do, as i think he will need to pass the id of the client on the b form for it to send the data.
a form (button) then after clicing button, b form show and the b form containing controls like open zipper, do back flip, etc.
May 30, 2018 11:24 AM
(This post was last modified: May 30, 2018 11:25 AM by 0xDEAD10CC.)
(May 29, 2018 07:48 AM)Dalvik Wrote: Or pass a reference to the class in the constructor of the B form.
Not the way to do it. If someone at a bank deposits a cheque for you do they let you go to the back and have access to everything so you can deposit it yourself?
Custom events, or dependency injection is a much better way. You want to be passing around data or references that only pertain to what you need. Packaging the data and sending it as an object to the constructor would be cleaner. This way if you needed 2-way manipulation the other side can re-receive the data after it has been manipulated.
DO NOT DEAL WITH THIS MEMBER
(May 30, 2018 11:24 AM)0xDEAD10CC Wrote: Not the way to do it. If someone at a bank deposits a cheque for you do they let you go to the back and have access to everything so you can deposit it yourself?
I find this analogy very weird, but I get what you mean. This can be solved with an interface though.
May 30, 2018 01:30 PM
(This post was last modified: May 30, 2018 01:31 PM by 0xDEAD10CC.)
(May 30, 2018 01:28 PM)Dalvik Wrote: I find this analogy very weird, but I get what you mean. This can be solved with an interface though.
An interface is for contracts, this is data, so it wouldn't make sense in this case. I'm talking more about an IoC container. The point I was trying to give, is that the whole point of encapsulation is to only give access to things that you want something else to have. By passing the form reference, you're giving that other object to change everything.
DO NOT DEAL WITH THIS MEMBER
May 30, 2018 01:35 PM
(This post was last modified: May 30, 2018 01:35 PM by Dalvik.)
(May 30, 2018 01:30 PM)0xDEAD10CC Wrote: An interface is for contracts, this is data, so it wouldn't make sense in this case. I'm talking more about an IoC container. The point I was trying to give, is that the whole point of encapsulation is to only give access to things that you want something else to have. By passing the form reference, you're giving that other object to change everything.
I never meant give a reference to a whole form to another form.
Also, what you said I already (partially) said before:
(May 29, 2018 07:08 AM)Dalvik Wrote: Depending on what you want to update this can be done in multiple wayse. If you want to for example update a listbox or listview or something on the other form, you can use databinding and pass a reference to a bindinglist to another form. Or you can use custom events. Whatever you want.
(May 30, 2018 01:35 PM)Dalvik Wrote: I never meant give a reference to a whole form to another form.
Also, what you said I already (partially) said before:
I did read that, but what I was quoting was this: "Or pass a reference to the class in the constructor of the B form"
|