Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8285137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:23:00+00:00 2026-06-08T11:23:00+00:00

I have a GUI with 10 rows and 4 columns. the purpose for it

  • 0

I have a GUI with 10 rows and 4 columns. the purpose for it is for me to enter in inputs into each box, and at the bottom, click the submit button where it will give me a file with all the inputs. The problem I am having is how can I code my “button” to do this? Help?

I am also having problems with my menustrip. Seems like everything is correct, but my visual won’t accept it. Is there something wrong with my code?

— It is my first time working with C# and visual, so any help will be much appreciated!

Public partial class Form 1 : Form
{


int count;
    Form mdiChild;
    TextBox editTextBox;

    public Form1()
    {
        InitializeComponent();
        count = 1;
    }

    private void newToolStripMenuItem_Click(object sender, EventArgs e)
    {
        mdiChild = new Form();
        mdiChild.Text = “Document” + count.ToString();
        mdiChild.MdiParent = this;
        editTextBox = new TextBox();
        editTextBox.Multiline = true;
        editTextBox.Dock = Dockstyle.Fill;
        mdiChild.Controls.Add(editTextBox);
        mdiChild.Show();
        count++;
    }

    private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();

        ofd.Title = “Open a Text File”;
        ofd.Filter = “Text File (*.txt)|*.txt|All Files (*.*)|*.*”;

        DialogResult dr = ofd.ShowDialog();
        If (dr == DialogResult.OK)
        {
            System.IO.StreamReader sr = new System.IO.StreamREader(ofd.FileName);

            Form activeChildForm = this.ActiveMdiChild;

            If (activeChildForm != null)
                 activeTextBox.Text = sr.ReadToEnd();

        {
            System.IO.StreamReader sr = new System.IO.StreamREader(ofd.FileName);

            Form activeChildForm = this.ActiveMdiChild;

            If (activeChildForm != null)
                 activeTextBox.Text = sr.ReadToEnd();

            sr.Close();
        }
    }
}

    private void saveToolStripMenuItem_Click(object sender, EventArgs e)
    {
        SaveFileDialog sfd = new SaveFileDialog();

        sfd.Title = “Save a Text File”;
        sfd.Filter = “Text File (*.txt)|*.txt|All Files (*.*)|*.*”;

        DialogResult dr = sfd.ShowDialog();
        If (dr == DialogResult.OK)
        {
            System.IO.StreamWriter sw = new System.IO.StreamWriter(sfd.FileName);

            Form activeChildForm = this.ActiveMdiChild;

            If (activeChildForm != null)
            {
                TextBox activeTextBox = (TextBox)activeChildForm.ActiveControl;

                If (activeTextBox != null)
                     sw.Write(activeTextBox.Text);

                sw.Close();
        }
    }
}

    private void cutToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Form activeChildForm = this.ActiveMdiChild;

        if (activeChildForm != null)
        {
            TextBox activeTextBox = (TextBox)activeChildForm.ActiveControl;
            if (activeTextBox != null)
                 activeTextBox.Cut();
        }
    }

private void copyToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Form activeChildForm = this.ActiveMdiChild;

        if (activeChildForm != null)
        {
            TextBox activeTextBox = (TextBox)activeChildForm.ActiveControl;
            if (activeTextBox != null)
                 activeTextBox.Copy();
        }
    }

private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Form activeChildForm = this.ActiveMdiChild;

        if (activeChildForm != null)
        {
            TextBox activeTextBox = (TextBox)activeChildForm.ActiveControl;
            if (activeTextBox != null)
                 activeTextBox.Paste();
        }
    }

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        String file_name = “C:\\test1.txt”;

        System.IO.StreamReader objReader;
        objReader = new System.IO.StreamReader(file_name)l

        textBox1.Text = objReader.ReadToEnd();

        objReader.Close();
    }

    Private void helpToolStripMenuItem_Click(object sender, EventArgs e)
    {
        System.Diagnostics.Process.Start (“    “);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:23:02+00:00Added an answer on June 8, 2026 at 11:23 am

    you should put the code in your button click. you might have to modify to code since your question was a bit confusing. I wasn’t sure if you wanted the input from controls or the gridview so I wrote the code for gridview

        namespace Test
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            const string path = @"C:\Kelimeler\Test.txt";
            private void Form1_Load(object sender, EventArgs e)
            {
                SqlConnection conn = new SqlConnection("Server=.;Database=Northwind; UID=sa;PWD=1234");
                SqlCommand cmd = new SqlCommand("Select ShipperID, CompanyName,Phone FROM Shippers", conn);
    
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dtSource = new DataTable();
                da.Fill(dtSource);
    
                dt.DataSource = dtSource;
    
                if (dt != null)
                {
                    if (!File.Exists(path))
                    {
                        File.Create(path);
                    }
    
                    foreach (DataGridViewRow row in dt.Rows)
                    {
                        for (int i = 0; i < dt.ColumnCount; i++)
                        {
                            File.AppendAllText(path, row.Cells[i].Value.ToString());
                            File.AppendAllText(path, ", ");
                        }
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GUI program with one Exit button. When clicking this button, it
I am making a small C# GUI application that reads table-like (cells, rows, columns)
I am embedding some QTableWidget(s) recursively inside of each other. The final GUI will
I have a GUI, which presents a table with thousands of rows and a
I have a GUI application whose main part is a QPlainTextEdit . It is
I have a GUI app that is getting to be quite slow. I want
I have a GUI that is going to do a lot of disparate tasks.
I have a GUI app written in C++/CLI which has a load of configurable
i have this GUI screen shots from the design team which i needs to
I have a GUI program, which would call a cmd in this GUI program.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.