Solved

c# make text this appear when condition is complete

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add different cell to otherwise similiar row 4 45
Problem!!! 8 37
Need a simple RegEx to search for two words 27 49
c# DateTime Format validation 4 47
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 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