I have a very basic question.
Scenario: 2 forms Form1, Form2- Dialog box which takes 3 inputs from the user
Form1 has a grid in which the user can select some cells.
Once the user makes a selection , the rowindex and colindex are stored in variable c1,c1,r1,r2
Form1:
private InsertRowsMethod(...)
{
float dv ;
GridRangeInfoList list;
Boolean b = theGrid.Selections.GetSelectedRanges(out list, true);
if (list.Count > 0)
{
r1= list.ActiveRange.Top;
c1 = list.ActiveRange.Left;
c2 = list.ActiveRange.Right;
}
DateTime dt;
frmDialog dialog = new frmDialog();
dialog.Show();
int dialognrows = Int32.Parse(dialog.textBox1.Text);
float dialogdv = float.Parse(dialog.textBox2.Text);
// var dttext = (DateTime.Parse(textBox3.Text)).Ticks;
TimeSpan dialogdt = TimeSpan.Parse(dialog.textBox3.Text);
for (int nc = insertc1; nc <= insertc2; nc++)
{
insertData(nc, insertr1, dialognrows, dialogdv, dialogdt, null);
}
}
In Form2:
It takes 3 parameters. nrows,time,value
Now I need to pass these 3 variables from Form2-Dialog to Form1.
I tried the Brute force way(which I would like to change, which I will come to it later)
In form2: I created method
private void button1_Click(object sender, EventArgs e)
{
int nrows = Int32.Parse(textBox1.Text);
float dv = float.Parse(textBox2.Text);
// var dttext = (DateTime.Parse(textBox3.Text)).Ticks;
TimeSpan dt = TimeSpan.Parse(textBox3.Text);
this.Hide();
}
So it worked, I was able to pass the three parameters nrows, dv, dt(user inputs) from dialog to form1-main form.
Question: I want the program in Form1 to wait,show the dialog, take user inputs and come back and continue to do this part.
for (int nc = insertc1; nc <= insertc2; nc++)
{
insertData(nc, insertr1, dialognrows, dialogdv, dialogdt, null);
}}
The dialog should show and then back to form1 to execute the insertdata
So Form2 is supposed to be a pop-up?
In that case when you create it, open it with
This will make the dialog box “modal”, which means that the user won’t be able to interact with the first form until they have dealt with this new form. Then if you have public properties in form 2 you should be able to access them in form 1.