LoginSignup
0
1

More than 5 years have passed since last update.

Visual Studio / WPF > 10 RadioButton、Picker、Image和ProgressBar控件 > DateTime? dl = DP_deadline.SelectedDate; | DateTime.Today | DateTime.Now | DateTime.UtcNow | DateTime.Now.ToShotDateString(); | DateTime.Now.ToShortTimeString()

Last updated at Posted at 2017-05-10
動作環境
Windows 7 Pro (32bit)
Microsoft Visual Studio 2017 Community
Sublime Text 2

10 RadioButton、Picker、Image和ProgressBar控件
https://www.youtube.com/watch?v=sDRsJCd_BOA&t=363s&list=WL&index=30

5:49あたり

DatePickerを使って、DateTime型変数に代入している。
初期状態はnullになるため、DateTime型はNullableとしている。

以下のように試してみた。

MainWinxow.xaml.cs
//省略//
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DateTime? dl = DP_deadline.SelectedDate;
            if (dl == null)
            {
                MessageBox.Show("Not selected");
            } else
            {
                MessageBox.Show(dl.ToString());
            }
        }
//省略//

未選択
work.png

選択後
work.png

7:28あたり

DateTime.Todayという値をDatePickerのSelectedDateに代入している。

他にもDateTime.NowDateTime.UtcNowというのが見つかった。

8:20あたり

DateTime.Nowに対してメソッドToShotDateString()というのが見えた。
他にもToShortTimeString()というのもあるようだ。

ToShotDateString()
work.png

ToShortTimeString()
work.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1