how to modify a textbox using remoting
I am trying to modify a textBox found in the server Form using remoting from the client side. i have tried some solutions i found, but none of them work.开发者_Go百科 the remoting part works propperly, the only thing that I am not able to figure out is this:
this is what i have: client side:
...
private void btn_b1_Click(object sender, EventArgs e)
{
...
myFunc.update(string s);
...
}
...
sharedLibs:
public interface myInterf
{
void update(string s);
}
server side:
here i have 2 classes in the same namespace
class class1 : MarshalByRefObject, myInterf
{
public void update(string s)
{
//what do i write here to modify textBox1?
}
}
public partial class class2 : Form
{
...
// here is the textBox i am trying to alter;
}
Your problem seems to be to find the instance of the Form class. If this is WinForms, you can use
var myForm = Application.OpenForms["formName"];
where formName is the the value of the Name property of the Form.
But please note:
- It is kind of strange to have a TextBox (or any UI) on a server, let alone to want to modify it from a client.
- remoting is an older (deprecated) technology. Make sure you know about WCF.
精彩评论