How to load the file from form2 back to form1

  • Thread starter Thread starter Mr STS
  • Start date Start date
M

Mr STS

Guest
I have two windows forms. Now i am trying to read the file from form2 and load it back to the main form which is form1. i will be loading it to the drivdiew.

form1(main form contains)
-loadbutton > when you click loadbutton it opens form2
-datagriview > the file will be loaded here on the grid

form2(second form contains)
-textbox > will disply the path
-browserbutton > will use to browser the file and read the file
-finish button > it must close form2 and open form1 with loaded file into the datagridview.

form1

private void btnBrowse1_Click(object sender, EventArgs e)
{
BrowseFile();
cboLanguage.Enabled = true;
btnNewfile.Enabled = true;
ReadFile(ref Gridview_Input, ref txtInputfile, ref cboLanguage, ref btnNewfile);
}

private void ReadFile(ref DataGridView _Grid, ref TextBox _InputTexBox, ref ComboBox _cboLanguage, ref Button _btnNew)
{
string PathSelection = "";
if (_InputTexBox.Text.Length > 0)
{
PathSelection = _InputTexBox.Text;
}
oDataSet = new DataSet();
XmlReadMode omode = oDataSet.ReadXml(PathSelection);

for (int i = 0; i < oDataSet.Tables[2].Rows.Count; i++)
{
string comment = oDataSet.Tables["data"].Rows[2].ToString();
string font = Between(comment, "[Font]", "[/Font]");
string datestamp = Between(comment, "[DateStamp]", "[/DateStamp]");
string commentVal = Between(comment, "[Comment]", "[/Comment]");
string[] row = new string[] { oDataSet.Tables["data"].Rows[0].ToString(), oDataSet.Tables["data"].Rows[1].ToString(), font, datestamp, commentVal };
_Grid.Rows.Add(row);
}
}

opening the second form

private void btnLoadfile_Click(object sender, EventArgs e)
{
this.Hide();
Program._FrmInputFile = new frmInputFile();
Program._FrmInputFile.Show();
}

Continue reading...
 
Back
Top