Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing data between forms in .NET
Message
De
29/06/2007 10:10:49
 
 
À
29/06/2007 09:10:51
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01236269
Message ID:
01236780
Vues:
11
Yassin,

I'd do what Mike suggested. If your TextBox on both Forms are bound to a DataSet, then when you open Form B (I assume it's to be modal? open it with .ShowDialog()), you can pass the DataSet as a parameter.

Form A
// Databind text box
this.MyTextBox.DataBind.Add("Text", MyDataSet.Tables["MyTable"], "MyColumn");

// Call FormB
FormB o = new FormB(MyDataSet);
o.ShowDialog();

// do other things with the new value of stuff in MyDataSet, that were set in FormB
FormB
private DataSet oData;

// constructor
public FormB(DataSet data)
{
    this.oData = data;
}

// load event (I typically databind from the Load event)
private void FormB_Load(object sender, EventArgs e)
{
    this.DataBind();
}
private void DataBind()
{
    this.MyTextBox.DataBind.Add("Text", this.oData.Tables["MyTable"], "MyColumn");
}
~~Bonnie




>Hi Bonnie,
>
>This is what I am trying to do, I have two forms A and B with a text box on each form. When someone types something on form A, I want to display form B with data populated on from the Form A text box to Form B text box. Once the user has done editing in Form B, I want to return the focus back on the text box on Form A.
>
>Thanks
>Yassin
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform