c# - Pasting values into DatetimePicker -


i have datetimepicker controls in c# windows application. of them formatted show date while others show time.

a user wants click on textbox field contains time in text format 14:25:56 , press ctrl + c. click on datetimepicker , press ctrl + v paste time date in datetimepicker.

it doesn't work default. possible make working @ all?

i did similar year ago pasting values data grid. handled putting event handler on keydown event of control want paste value into, can use event args check of characters (in case, v) pressed , modifier keys (ctrl, shift, alt, etc.) pressed.

once know ctrl+v pressed, can create code parse through string returned clipboard.gettext(); using datetime.parse(); defined on msdn , store value in date-time picker. here got. want validation make sure text in right format. can datetime.tryparse(); instead of datetime.parse() using.

private void datetimepicker1_keydown(object sender, keyeventargs e) {     if (e.modifiers == keys.control && e.keycode == keys.v)     {         datetimepicker1.value = datetime.parse(clipboard.gettext());         e.handled = true;     } } 

i hope helps.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -