Solved

Clear text from a control that is on another form

Posted on 2013-10-28
2
285 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now