[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Clear text from a control that is on another form

Posted on 2013-10-28
2
Medium Priority
?
302 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 86

Accepted Solution

by:
Mike Tomlinson earned 1000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Screencast - Getting to Know the Pipeline
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

831 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