private void TsmPaste_Click(object sender, EventArgs e) { if (DatePickerValue.TryParse(Clipboard.GetText(), out DatePickerValue dv)) { this.Value = dv; } }
private void Cms_Opening(object sender, CancelEventArgs e) { tsmEmpty.Enabled = tsmCopy.Enabled = !this.Value.IsEmpty; tsmPaste.Enabled = false; if (Clipboard.ContainsText()) { if (DatePickerValue.TryParse(Clipboard.GetText(), out DatePickerValue dv)) { tsmPaste.Enabled = true; } } }
private void TxtShowDate_KeyDown(object sender, KeyEventArgs e) { e.SuppressKeyPress = true; if (e.KeyData == (Keys.Control | Keys.V)) { if (Clipboard.ContainsText()) { if (DatePickerValue.TryParse(Clipboard.GetText(), out DatePickerValue dv)) { this.Value = dv; } } } else if (e.KeyData == (Keys.Control | Keys.C) && txtShowDate.SelectionLength > 0) { Clipboard.SetText(txtShowDate.Text); } else if (e.KeyCode == Keys.Delete) { this.Value = new DatePickerValue(); } }