I have two forms Form1 and Form2.
on Form1 button click , I want to open form2 in which yes and no buttons are there in the form2.
When user click on button yes, form1 textbox should display the value in form1's textbox.
What i have done is as follows:
On Form1
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Alert AlertObj = new Alert();
string a=AlertObj.Text.Length.ToString();
string val=Alert.buttonVal();
AlertObj.Show();
if (val == "Yes")
textBox1.Text = val;
else
textBox1.Text = "No";
}
}
on Form 2
public partial class Alert : Form
{
public Alert()
{
InitializeComponent();
}
public static string result = string.Empty;
private void button1_Click(object sender, EventArgs e)
{
result = "Yes";
Form1 obj = new Form1();
this.Close();
}
public static string buttonVal()
{
return result;
}
}
MessageBox
withYes
andNo
buttons?? – Shaharyar