Passer une variable bool de la form2 a la form1 principale ouverte deja

Résolu
ziedmechri - 10 août 2012 à 13:21
Tupad Messages postés 239 Date d'inscription lundi 5 décembre 2005 Statut Membre Dernière intervention 27 août 2012 - 10 août 2012 à 15:29
qui pourra m'aider sur ce sujet vraiment çà fait 1 semaine a chercher
code form1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}
public Form1(bool a)
{
InitializeComponent();
textBox1.Text = a.ToString();

}





private void button1_Click(object sender, EventArgs e)
{
Form2 fr = new Form2();

fr.Show();

}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}


}
}

code form2


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{


public Form2()
{
this.InitializeComponent();


}

private void button1_Click(object sender, EventArgs e)
{
Form1 fr = new Form1(true);
this.Close();

}




}
}

se code ne retourne aucun résulta.

3 réponses

Tupad Messages postés 239 Date d'inscription lundi 5 décembre 2005 Statut Membre Dernière intervention 27 août 2012 5
10 août 2012 à 14:12
depuis la form1, tu déclares form2 comme variable de classe
dans la form2, tu crées une propriété à laquelle tu pourras accéder depuis la form1
3
comment crées une propriété je suis debutant
0
Tupad Messages postés 239 Date d'inscription lundi 5 décembre 2005 Statut Membre Dernière intervention 27 août 2012 5
10 août 2012 à 15:29
Un exemple dans lequel la valeur de la propriété est stocké dans une textbox

public string Property
{
get { return this.textbox1.Text;}
set { this.textbox1.Text = value;}
}
0
Rejoignez-nous