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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:18:43+00:00 2026-06-11T13:18:43+00:00

private void button2_Click(object sender, EventArgs e) { ChangeLink cl = new ChangeLink(); // Show

  • 0
private void button2_Click(object sender, EventArgs e)
        {
            ChangeLink cl = new ChangeLink();
            // Show testDialog as a modal dialog and determine if DialogResult = OK.
            if (cl.ShowDialog() == DialogResult.OK)
            {
                // Read the contents of testDialog's TextBox. 
               // cl.AcceptButton.DialogResult = DialogResult.OK;
                this.label4.Text = cl.textBox1Text;
            }
            else
            {
                this.label4.Text = "Cancelled";
            }
            cl.Dispose();

        }

When I click the button, I see the new Form and the textBox1 in the new Form. And I can type in the textBox1 something, but I can’t see anywhere an OK or CANCEL buttons. Should I add them manualy in the new Form designer? And how to use them then?

This is the code in my new Form what I wanted to do is to type something in the new Form textBox1 and pass the text in the textBox1 to Form1 label4.

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 GatherLinks
{
    public partial class ChangeLink : Form
    {
        public ChangeLink()
        {
            InitializeComponent();


        }

        public string textBox1Text
        {
            get
            {
                return textBox1Text = textBox1.Text;
            }
            set
            {
               
            }
        }
    }
}

So where are the OK and CANCEL buttons of the Form.ShowDialog?

  • 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-11T13:18:44+00:00Added an answer on June 11, 2026 at 1:18 pm

    You will need to add them yourself, you can add the buttons to your Form and set their DialogResult Property. This will return the DialogResult and close the Form without you having to wire up any code. Here is an example using a Method to return the Value of The TextBox on Form2(There are two Buttons on Form2 with their DialogResults set to Cancel and Ok respectivly).

    Form1

    public partial class Form1 : Form
    {
        Form2 frm2;
        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            frm2 = new Form2();
            DialogResult dr = frm2.ShowDialog(this);
            if (dr == DialogResult.Cancel)
            {
                frm2.Close();
            }
            else if (dr == DialogResult.OK)
            {
                textBox1.Text = frm2.getText();
                frm2.Close();
            }
        }
    }
    

    Form2

    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
    
        public string getText()
        {
            return textBox1.Text;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private void button2_Click(object sender, EventArgs e) { cl = new ChangeLink(); cl.StartPosition = FormStartPosition.CenterParent;
private void button2_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(Data Source=SYS12;Initial Catalog=Teju;Integrated
private void button2_Click(object sender, EventArgs e) { int i = 5; MessageBox.Show(i); } Fails..
I have this code: private void button2_Click(object sender, EventArgs e) { //add pgs selected
private void button2_Click(object sender, EventArgs e) { //read in file data and calculate record
private void button1_Click(object sender, EventArgs e) { for (int i = 0; i <
When I run the following code: private void button1_Click(object sender, EventArgs e) { Bitmap
I tried to login to gmail with the code: private void button1_Click(object sender, EventArgs
private void btnSend_Click(object sender, RoutedEventArgs e) { Button obj=(Button)sender; obj.Content=Cancel; SendImage send = new
This is my code: private void button1_Click(object sender, EventArgs e) { DataTable table =

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.