How To: Get Selected Date from MonthCalendar control

Posted by: Sushila Patels Weblog, on 16 Aug 2006 | View original | Bookmarked: 0 time(s)

VB.NET

Private Sub MonthCalendar1_DateChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged

'Display the dates for selected range
Label1.Text = "Dates Selected from :" & (MonthCalendar1.SelectionRange.Start() & " to " & MonthCalendar1.SelectionRange.End)

'To display single selected of date
'MonthCalendar1.MaxSelectionCount = 1

'To display single date use MonthCalendar1.SelectionRange.Start/ MonthCalendarSelectionRange.End
Label2.Text = "Date Selected :" & MonthCalendar1.SelectionRange.Start

End Sub

C#

private void MonthCalendar1_DateChanged(object sender, System.Windows.Forms.DateRangeEventArgs e)
{
//Display the dates for selected range
Label1.Text = "Dates Selected from :" + (MonthCalendar1.SelectionRange.Start() + " to " + MonthCalendar1.SelectionRange.End);

//To display single selected of date
//MonthCalendar1.MaxSelectionCount = 1;

//To display single selected of date use MonthCalendar1.SelectionRange.Start/ MonthCalendarSelectionRange.End
Label2.Text = "Date Selected :" + MonthCalendar1.SelectionRange.Start;
}

Share this post: Email it! | bookmark it! | digg it! | reddit!

Category: VB.NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 17920 | Hits: 131

Similar Posts

  • SQL SERVER Denali Date and Time Functions DATEFROMPARTS() DATETIMEFROMPARTS() DATETIME2FROMPARTS() TIMEFROMPARTS() SMALLDATETIMEFROMPARTS() DATETIMEOFFSETFROMPARTS() A Quick Introduction more
  • Designer v Xaml v Code more
  • Eschewing Date Types in our Database more
  • Changing DatePicker in Silverlight to show current date more
  • LINQ Tip of the week: System.DateTime support more
  • Building a class browser with Microsoft Ajax 4.0 Preview 5 more
  • API changes introduced by the new CoverFlow control more
  • TreeView in ComboBox, take 3 (Silverlight 3, WPF and RadControls) more
  • WebResource access in ASP.NET MVC more
  • Silverlight 3 Multi-touch: The Basics more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD