Jump to content

Time&Date Picker

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Coder_Abdul

Coder_Abdul

    Newbie

  • Members
  • Pip
  • 8 posts
i try to make this code

            if (pr_NumberTextBox.Text == "" || create_dateDateTimePicker.Text == "")

            {

                MessageBox.Show("Error");

            }

if pr_NumberTextBox == null then Error
or
create_dateTimePicker == null then Error

but

The problem is with dateTimePicker it does not become empty . Because of that there is a default value . i just ask if can i do it empty??

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
Try using the .IsNullOrEmpty() member function to test for a string being null. Like so:

create_dateDateTimePicker.Text.IsNullOrEmpty()

Let me know if that works.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3
Coder_Abdul

Coder_Abdul

    Newbie

  • Members
  • Pip
  • 8 posts
does not work ...

#4
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts
DateTimePicker always has a value so there is no need to check if it has a value.

#5
Coder_Abdul

Coder_Abdul

    Newbie

  • Members
  • Pip
  • 8 posts
i think , i will try to do another idea in this form ... I was just help my friends in their graduation project, the prison management system. i need to tell users error message when they click save button to save data if pr_number or create_date are empty.
I think ,, I'm going to bring many questions here.
Thank you gregwarner , Thank you Momerath ...

#6
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts

gregwarner said:

Try using the .IsNullOrEmpty() member function to test for a string being null. Like so:

create_dateDateTimePicker.Text.IsNullOrEmpty()

IsNullOrEmpty is a static method (if the string was null, there wouldn't be anything to call :)). So it's used like:
if (String.IsNullOrEmpty(someStringValue)) { // it's null, or empty!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users