Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to load the file from form2 back to form1

$
0
0
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[i][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[i][0].ToString(), oDataSet.Tables["data"].Rows[i][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();
        }

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>