Solved

c# make text this appear when condition is complete

Posted on 2010-11-25
4
372 Views
Last Modified: 2012-05-10
this.labelStart.Text = "Hello World";

when user select  both folder the label  "Hello World" still not appear how can I clear it
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;

using System.IO;



namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }



        private void button1_Click(object sender, EventArgs e)

        {

            FolderBrowserDialog dlg = new FolderBrowserDialog();

            if (dlg.ShowDialog() == DialogResult.OK)

            {

                sorrceTextbox.Text = dlg.SelectedPath;

            }





        }





        private void textBox1_TextChanged(object sender, EventArgs e)

        {



        }



        private void button2_Click(object sender, EventArgs e)

        {

            FolderBrowserDialog dlg2 = new FolderBrowserDialog();

            if (dlg2.ShowDialog() == DialogResult.OK)

            {

                destTextbox.Text = dlg2.SelectedPath;

            }



        }



        private void textBox2_TextChanged(object sender, EventArgs e)

        {



        }



        private void startcopy_Click(object sender, EventArgs e)

        {

            if (String.IsNullOrEmpty(sorrceTextbox.Text) || String.IsNullOrEmpty(destTextbox.Text))

            {

               this.labelStart.Text = "Hello World";

            }

        }



        private void label1_Click(object sender, EventArgs e)

        {

            

        }





    }

}

Open in new window

0
Comment
Question by:teera
  • 2
4 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 34215397
Your condition, as I read it, is to show "Hello World" when either box has no text in it (i.e. either one or both are empty). Is that correct?
0
 
LVL 9

Accepted Solution

by:
AnilKumarSharma earned 250 total points
ID: 34215417
First you need to understand when the label will appear. Your code shows that it will appear when you click startcopy button.
Secondly you need to clear what condition is given in startcopy to display the label. It is if ANY of the text box (source or destination is empty then show the label. Looks that in your conditon you already clciked both buttons button1 and button2 that cause both text box to be filled with some path. Now the startcopy will never be true and hence it will never print the "helloworld". You can do the following to clear the text box.
In this case even when you clciked the button1 and button2, it will clear the both text boxs and then when you click again the startcopy , it will display the hello world. Note that you need to sure at what condtion you like to display the hello world. You can change that. The code is attached.
private void startcopy_Click(object sender, EventArgs e)

        {

            if (String.IsNullOrEmpty(sorrceTextbox.Text) || String.IsNullOrEmpty(destTextbox.Text))

            {

                this.labelStart.Text = "Hello World";

            }

            sorrceTextbox.Text = "";

            destTextbox.Text = "";





        }

Open in new window

0
 

Author Comment

by:teera
ID: 34215429
hi      kaufmed

 yes
 
hi     AnilKumarSha…

 I want word  "Hello World"  world this apear  

   like when user select sorce and destination then program start to copy

0
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
ID: 34215542
>>  like when user select sorce and destination then program start to copy

It's not going to show when your user selects from the two dialogs because you set it to show ONLY when 1 or both boxes don't have anything in them. I think you mean the following:
private void startcopy_Click(object sender, EventArgs e)
{
    if (!String.IsNullOrEmpty(sorrceTextbox.Text) && !String.IsNullOrEmpty(destTextbox.Text))
    {
        this.labelStart.Text = "Hello World";
    }
}

Open in new window

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

20 Experts available now in Live!

Get 1:1 Help Now