在文本框中显示日历中的选定日期。 [英] Display selected date from calender in a textbox.
问题描述
任何人都可以帮助我从月份日历中获取所选日期,进入Windows窗体的文本框。 Monthcalender控件和文本框的格式相同。
sammy
嗨sammy979
据我所知,如果我们假设表格有两个控件,一个是Monthcalender,名为monthcalender1,另一个是TextBox,名为textbox1,如果我们想将所选日期从Monthcalender变为TextBox,我们可以
使用以下代码:
This.textbox1.Text = This.monthcalendar1。
SelectionStart
。ToShortDateString();
也许它不是你想要的格式,然后,您可以获取引用该网站的其他格式:
http://msdn.microsoft.com/en-us/library/System.Windows.Forms.MonthCalendar_properties(v=vs.110).aspx ,这将告诉你MonthCalender的详细用法。
祝你好运
贝
Hi,
Can anybody please help me in getting the selected date from monthcalender , into a textbox in Windows Forms. Monthcalender control and textbox are in the same form.
sammy
Hi sammy979
As far as I know, if we assume that the form has two controls, the one is Monthcalender named monthcalender1 and the other one is TextBox named textbox1, if we want to get the selected date from Monthcalender into TextBox, we can use the following code:
This.textbox1.Text = This.monthcalendar1. SelectionStart .ToShortDateString();
Maybe it is not the format you want, then, you can get the other format referring to the site: http://msdn.microsoft.com/en-us/library/System.Windows.Forms.MonthCalendar_properties(v=vs.110).aspx, which will tell you the detail usage of MonthCalender.
Best regards
Tony
这篇关于在文本框中显示日历中的选定日期。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!