Solved

Clear text from a control that is on another form

Posted on 2013-10-28
2
296 Views
Last Modified: 2013-10-29
Hey guys!!

I have a form with a combo box control and a button.  After I make a selection from the comb box I can click the button and it opens another form with the details of the selection from the combo box.

When I delete the details on the second form I want also to delete the text from the combo box.

I have tried a get/set and another that I set the control to Public then open a second instance of the form and delete the text and I can't make either work.

There must be a way to do this!!

Any help would be appreciated.

Thanks,
Jerry
0
Comment
Question by:JDL129
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 39607753
Display the second form with ShowDialog().  In the second form, set DialogResult to OK  or Cancel.

The first form:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // ... open up the second form based on the combobox selection ...
            Form2 f2 = new Form2();
            if (f2.ShowDialog() == System.Windows.Forms.DialogResult.OK) // code stops here until f2 is dismissed
            {
                // ... remove the value from the combobox ...
            }
        }
    }

Open in new window

In the second form:
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }

Open in new window

0
 

Author Closing Comment

by:JDL129
ID: 39608554
I wish I could give you a thousand points!!!!!  :-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Service Controller 1 28
Disable Security Alert  popup in Winforms  embedded webbrowser. 1 57
VB: Convert 2 dates to specific format 24 53
linq, c# 8 25
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question