windows formulaires récupérer valeur textbox
bonjour,
j'aimerais récupérer les valeurs de mes textbox qui appartiennent à un form2.
car quand je les tapes dans mon form1, ils ne sont pas reconnu.
Quelqu'un peut m'aider. Voici le nom de mes textBox :
Code:
1 2 3
| txtBoxMDP.Text;
txtBoxUserName.Text ;
txtBoxURL.Text; |
Une solution horrible, je sais
Bonjour,
code pour le 1er écran
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
[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 Test_entreécrans
{
public partial class Form1 : Form
{
public static String form1user = "";
public static String form1password = "";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void connexionBtn_Click(object sender, EventArgs e)
{
Form connexionFrm = new Form2();
DialogResult p_ret = connexionFrm.ShowDialog();
userTextBox.Text = form1user;
passwordTextBox.Text = form1password;
this.Refresh();
}
}
} |
pour le 1er écran où l'on affiche l'utilisateur et le mot de passe saisis dans le 2ème écran
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
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 Test_entreécrans
{
public partial class Form1 : Form
{
public static String form1user = "";
public static String form1password = "";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void connexionBtn_Click(object sender, EventArgs e)
{
Form connexionFrm = new Form2();
DialogResult p_ret = connexionFrm.ShowDialog();
userTextBox.Text = form1user;
passwordTextBox.Text = form1password;
this.Refresh();
}
}
} |
Si vous avez des problème avec mon code, n'hésitez pas à poster à nouveau
Bonne journée