Solved

c# make text this appear when condition is complete

Posted on 2010-11-25
4
373 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 75

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 75

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

919 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

21 Experts available now in Live!

Get 1:1 Help Now