Этот элемент управления похож на поле с выпадающим списком, где вместо списка, выпадает календарь.
символы заполнители пользовательского формата |
||
символ |
описание |
отображение |
| dd | день месяца в диапазоне 1—31 | 24 |
| ddd | неполное название дня | Пн |
| dddd | полное название дня | понедельник |
| MM | месяц как число | 09 |
| MMM | неполное название месяца | сен |
| MMMM | полное название месяца | Сентябрь |
| yy | год в двух цифрах | 12 |
| yyyy | год в четырех цифрах | 2012 |
| gg | эра, A.D. — anno Domini, н.э. | A.D. |
| hh | часы в диапазоне 0-12 | 10 |
| tt | АМ — до полудня, РМ — после полудня | РМ |
| HH | часы в диапазоне 0-23 | 22 |
| mm | минуты | 34 |
| ss | секунды | 39 |
| fff | миллисекунды | 783 |
Form1.cs
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0041 {-
publicpartialclassForm1 : Form { -
publicForm1() { -
InitializeComponent(); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
textBox1.Text = dateTimePicker1.Text; -
} -
privatevoidbutton2_Click(objectsender, EventArgs e) { -
textBox2.Text = dateTimePicker2.Text; -
} -
privatevoidbutton3_Click(objectsender, EventArgs e) { -
textBox3.Text = dateTimePicker3.Text; -
} -
privatevoidbutton4_Click(objectsender, EventArgs e) { -
textBox4.Text = dateTimePicker4.Text; -
} -
privatevoidbutton5_Click(objectsender, EventArgs e) { -
//програмно раскрываем календарь -
//устанавливаем фокус на элемент -
dateTimePicker5.Focus(); -
//создаем эмуляцию нажатия кнопки F4 -
SendKeys.Send("{F4}"); -
} -
} }
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0041 {-
publicpartialclassForm1 : Form { -
publicForm1() { -
InitializeComponent(); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
textBox1.Text = dateTimePicker1.Text; -
} -
privatevoidbutton2_Click(objectsender, EventArgs e) { -
textBox2.Text = dateTimePicker2.Text; -
} -
privatevoidbutton3_Click(objectsender, EventArgs e) { -
textBox3.Text = dateTimePicker3.Text; -
} -
privatevoidbutton4_Click(objectsender, EventArgs e) { -
textBox4.Text = dateTimePicker4.Text; -
} -
privatevoidbutton5_Click(objectsender, EventArgs e) { -
//програмно раскрываем календарь -
//устанавливаем фокус на элемент -
dateTimePicker5.Focus(); -
//создаем эмуляцию нажатия кнопки F4 -
SendKeys.Send("{F4}"); -
} -
} }