Solved

c# make text this appear when condition is complete

Posted on 2010-11-25
4
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

617 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