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 8665281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:26:41+00:00 2026-06-12T17:26:41+00:00

This question is the followup to the following question: C# Text don't display on

  • 0

This question is the followup to the following question:
C# Text don't display on another form after double clicking an item in listbox

Now I have typed my value in the textbox of form3. How am I going to pass back the value to form1 to show it in the listbox10 after pressing “OK” in form3? Below is my form3 coding but it don’t work:

private void button1_Click(object sender, EventArgs e)
{   
    //This is the coding for "OK" button.
    int selectedIndex = listBox10.SelectedIndex;
    listBox10.Items.Insert(selectedIndex, textBox1.Text);
}
  • 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-12T17:26:42+00:00Added an answer on June 12, 2026 at 5:26 pm

    You can put public property on form3:

    public partial class form3 : Form
    {
        public String SomeName
        {
            get
            {
                return textbox1.Text;
            }
        }
    
        ...
        private void buttonOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }
    
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }
     }
    

    In form1, where you are open form3, after ShowDialog, you will write:

    if (form3.ShowDialog() == DialogResult.OK)
    {
    
        int selectedIndex = listBox10.SelectedIndex;
    
        if (selectedIndex == -1) //listbox does not have items
            listbox10.Add(form3.SomeValue);
        else
            listBox10.Items.Insert(selectedIndex, form3.SomeName);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a followup on the question: ASP.NET next/previous buttons to display single row
This is a followup to my last question . I now have a byte[]
This is a followup of this question in the following code, why does line
This is a followup question to another question I asked earlier. I thought I
This is a followup to another question I asked earlier ( Earlier redirect question
This is kind of a followup to this question . I have the following
This is a followup to this question . Since the problem that I'm now
Follow up to this question . I have the following code: string[] names =
This is a follow-up question to the following if you would like to see:
As a followup to this question , is it possible to write a single

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.