Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

c# make text this appear when condition is complete

Posted on 2010-11-25
4
Medium Priority
?
389 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 1000 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 1000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

876 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