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 8697501

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:32:28+00:00 2026-06-13T01:32:28+00:00

I have the following form. The first button opens a text file and displays

  • 0

I have the following form. The first button opens a text file and displays the file in the rich text box in the form. The second button opens another window. What I want is for that window to be pre-populated with the data that is in that text file…

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HomeInventory2
{
    public partial class Form2 : Form
    {
        OpenFileDialog openFileDialog1 = new OpenFileDialog();
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                richTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.RichText);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Run(new Form1());
        }
    }
}

The form that needs to be populated

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HomeInventory2.Domain;
using HomeInventory2.Business;

namespace HomeInventory2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void submitButton_Click(object sender, EventArgs e)
        {
            CreateInventory create = new CreateInventory();
            create.ItemAmount = textBoxAmount.Text;
            create.ItemCategory = textBoxCategories.Text;
            create.ItemProperties = textBoxValue.Text;
            create.ItemValue = textBoxValue.Text;

            InventoryMngr invtryMngr = new InventoryMngr();
            invtryMngr.Create(create);

        }
    }
}
  • 0 0 Answers
  • 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-13T01:32:29+00:00Added an answer on June 13, 2026 at 1:32 am

    Create a new constructor which takes a string overload. When you open the new Form, pass in the text date and fill the textbox.

    //in the new form that opens up
    public Form1(string prepopulated)
    {
        InitializeComponent();
        myRichTextbox.Text = prepopulated;
    }
    

    And call it from your click event like this:

    //in the first form
    private void button2_Click(object sender, EventArgs e)
    {
        Application.Run(new Form1(richTextBox1.Text));
    }
    

    If your content is more complicated than a simple text file, you can use RichTextBox.Document instead and pass that instead of the string. Change the overload to

    Form1(FlowDocument prepopulated)
    

    and call it like this

    Application.Run(new Form1(richTextBox1.Document));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 forms set up. In the first form I have the following
i have two form as following <form id=form1 action=/Account/form1> <input type=text name=baar /> <input
If I run following code in the playground: var button1 = new qx.ui.form.Button(First Button,
I have simple form set up like the following: <form> <input type=text name=first_number id=first_number
I have the following code... <h3>Guests</h3> <form class=form-inline> <fieldset> <label class=control-label for=input01>First Name:</label> <input
I have the following form in a Struts2 JSP that contains some radio buttons.
I have the following form: @model Teesa.Models.SearchModel @using (Html.BeginForm(Index, Search, FormMethod.Get, new { id
I have the following form and controller. <%= form_tag do %> <div> <%= label_tag
I have the following form: echo $this->Form->input('Person.name'); echo $this->Form->input('Person.phone'); echo $this->Form->input('Person.email'); echo $this->Form->input('Message.0.plainmsg'); echo
I have the following form, which I have reduced as much as I can,

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.