Napraviš form2 sa jednim txtbox i sledećim metodama
Code:
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public void setText(string s)
{
textBox1.Text = s;
}
public string getText()
{
return textBox1.Text;
}
public void clearText()
{
textBox1.Text = string.Empty;
// ili textBox1.Clear();
}
public int getTextLength()
{
return textBox1.Text.Length;
}
}
I napraviš form1 sa recimo 3 button-a
Code:
public partial class Form1 : Form
{
private Form2 f;
public Form1()
{
InitializeComponent();
f = null;
}
private void button1_Click(object sender, EventArgs e)
{
f = new Form2();
f.Show();
}
private void button2_Click(object sender, EventArgs e)
{
if (f != null)
MessageBox.Show(f.getText());
}
private void button3_Click(object sender, EventArgs e)
{
if (f != null)
f.setText("Default text");
}
}
Experimentiši malo.
Sledeći put izbegavaj slanje PP. Kad budem imao vremena odgovoriću na forumu, a ne putem PP.
77 77 77 2E 65 73 6E 69 70 73 2E 63 6F 6D