Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 90483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:52:49+00:00 2026-05-10T22:52:49+00:00

How do you perform databinding against the MonthCalendar.SelectionRange property? Given the property is of

  • 0

How do you perform databinding against the MonthCalendar.SelectionRange property? Given the property is of type ‘SelectionRange’ which is a class I am not sure how to go about it. Any examples would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:52:50+00:00Added an answer on May 10, 2026 at 10:52 pm

    Well, there don’t seem to be any obvious events for this either on the MonthCalendar or the SelectionRange, and neither implements INotifyPropertyChanged, so it looks like data-binding might not be possible here.

    Update: It does, however, raise the DateChanged, so you could hook some stuff together manually, or (more usefully) by subclassing the control to expose the values and events in a fashion suitable for binding. Note the Actual(...) are useful because the end (otherwise) is just before midnight, rather than midnight itself…

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Windows.Forms; class Foo : INotifyPropertyChanged {     public event PropertyChangedEventHandler PropertyChanged;     protected virtual void OnPropertyChanged(string propertyName)     {         var handler = PropertyChanged;         if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));         Debug.WriteLine(ToString());     }     private void SetField<T>(ref T field, T value, string propertyName)     {         if (!EqualityComparer<T>.Default.Equals(field, value))         {             field = value;             OnPropertyChanged(propertyName);                     }     }     private DateTime start, end;     public DateTime Start { get { return start; } set { SetField(ref start, value, 'Start'); } }     public DateTime End { get { return end; } set { SetField(ref end, value, 'End'); } } }  class BindableCalendar : MonthCalendar {     public DateTime ActualSelectionStart     {         get { return SelectionRange.Start; }         set { if (ActualSelectionStart != value) { SetSelectionRange(value, ActualSelectionEnd); } }     }     public DateTime ActualSelectionEnd     {         get { return SelectionRange.End; }         set { if (ActualSelectionEnd != value) { SetSelectionRange(ActualSelectionStart, value); } }     }     // should really use EventHandlerList here...     public event EventHandler ActualSelectionStartChanged, ActualSelectionEndChanged;      DateTime lastKnownStart, lastKnownEnd;     protected override void OnDateChanged(DateRangeEventArgs drevent)     {         base.OnDateChanged(drevent);         if (lastKnownStart != drevent.Start)         {             if (ActualSelectionStartChanged != null) ActualSelectionStartChanged(this, EventArgs.Empty);             lastKnownStart = drevent.Start;         }         if (lastKnownEnd != drevent.End)         {             if (ActualSelectionEndChanged != null) ActualSelectionEndChanged(this, EventArgs.Empty);             lastKnownEnd = drevent.End;         }     }  }  static class Program {     [STAThread]     static void Main()     {          Application.EnableVisualStyles();         MonthCalendar cal;         Button btn;         using (Form form = new Form         {             Controls = {                 (cal = new BindableCalendar { Dock = DockStyle.Fill, MaxSelectionCount = 10 }),                 (btn = new Button { Dock = DockStyle.Bottom, Text = 'thwack'})             }         })         {             Foo foo = new Foo { Start = DateTime.Today, End = DateTime.Today.AddDays(1) };             cal.DataBindings.Add('ActualSelectionStart', foo, 'Start').DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;             cal.DataBindings.Add('ActualSelectionEnd', foo, 'End').DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged;             btn.Click += delegate             {                 foo.Start = foo.Start.AddDays(1);                 foo.End = foo.End.AddDays(1);             };             Application.Run(form);         }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this controller which performs me a multiple domain databinding class, and it
I need to perform a find and replace using XSLT 1.0 which is really
I found an example online that explains how to perform databinding to a ListBox
I'm trying to perform the following query in LLBL and I'm not having much
I'm buidling an WPF application using the examples given in the link below as
I perform some checks in my Window class constructor, and if they fail I
I perform some checks during configure, which i set up with autoconf using the
I perform an AJAX request to a PHP script in JavaScript and by using
I perform slaveOk reads on a mongo (2.0.3) secondary. I wish to do so,
I'm trying perform a relatively basic TCP socket send/receive operation on Windows CE using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.