passing data between forms
-
Hi, I have a dll class and from here I am calling a form. I am able to send data from the dll class to the form. But how I am going to get data back from the form to the dll class? I wsed the same code but it is not working backward.
frmLogin login = new frmLogin();
login.Type = type; login.Username = username; login.Password = password; login.Group = group; login.ShowDialog();
Thanks in advance, Sai
-
Hi, I have a dll class and from here I am calling a form. I am able to send data from the dll class to the form. But how I am going to get data back from the form to the dll class? I wsed the same code but it is not working backward.
frmLogin login = new frmLogin();
login.Type = type; login.Username = username; login.Password = password; login.Group = group; login.ShowDialog();
Thanks in advance, Sai
Why can't you simply reverse the assignments you have?
login.ShowDialog();
username = login.Username;
password = login.Password;etc....
The difficult we do right away... ...the impossible takes slightly longer.
-
Hi, I have a dll class and from here I am calling a form. I am able to send data from the dll class to the form. But how I am going to get data back from the form to the dll class? I wsed the same code but it is not working backward.
frmLogin login = new frmLogin();
login.Type = type; login.Username = username; login.Password = password; login.Group = group; login.ShowDialog();
Thanks in advance, Sai
Create a property (or several) in the Form and read it back from the instance once ShowDialog returns - it won't until the user closes the form, so read the data at that point.
frmLogin login = new frmLogin(); login.Type = type; login.Username = username; login.Password = password; login.Group = group; login.ShowDialog(); type = login.Type; username = login.Username; password = login.Password; group = login.Group;
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Create a property (or several) in the Form and read it back from the instance once ShowDialog returns - it won't until the user closes the form, so read the data at that point.
frmLogin login = new frmLogin(); login.Type = type; login.Username = username; login.Password = password; login.Group = group; login.ShowDialog(); type = login.Type; username = login.Username; password = login.Password; group = login.Group;
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
What I did.... In Class 1
if (login.ShowDialog()== DialogResult.OK)
{
ans= login.Result;
}In form 1
public int Result
{
get;
set;
}Result = value;
this.DialogResult = DialogResult.OK;Thnks a lot all, Sai
That'll do it! Nice one - well done.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
What I did.... In Class 1
if (login.ShowDialog()== DialogResult.OK)
{
ans= login.Result;
}In form 1
public int Result
{
get;
set;
}Result = value;
this.DialogResult = DialogResult.OK;Thnks a lot all, Sai
I can't make any connection between the code you show here, and any other post on this thread: This code is not going to compile: 1. the variable 'ans is never declared, or used, just assigned to; will not compile. 2. the variable 'value is never declared: Result = value; will not compile. 3. the statement: "this.DialogResult = DialogResult.OK;" makes no sense unless you have a Form1 scoped variable with the name 'DialogResult declared, and, you should not use variable names identical to Operator names since that way lies utter code confusion. And why would you need a Form1 scoped variable of this type in the first place ? This is a case where posting code-fragments means no meaningful response is possible. best, Bill
"If you shoot at mimes, should you use a silencer ?" Stephen Wright
-
I can't make any connection between the code you show here, and any other post on this thread: This code is not going to compile: 1. the variable 'ans is never declared, or used, just assigned to; will not compile. 2. the variable 'value is never declared: Result = value; will not compile. 3. the statement: "this.DialogResult = DialogResult.OK;" makes no sense unless you have a Form1 scoped variable with the name 'DialogResult declared, and, you should not use variable names identical to Operator names since that way lies utter code confusion. And why would you need a Form1 scoped variable of this type in the first place ? This is a case where posting code-fragments means no meaningful response is possible. best, Bill
"If you shoot at mimes, should you use a silencer ?" Stephen Wright