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

  • Home
  • SEARCH
  • 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 7918713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:36:10+00:00 2026-06-03T15:36:10+00:00

I logged the issue with Microsoft here – the Repro is available for download:

  • 0

I logged the issue with Microsoft here – the Repro is available for download: https://connect.microsoft.com/VisualStudio/feedback/details/741454/value-change-event-doesnt-fire-for-datetimepicker-controls-used-in-vsto-add-ins

If you put a DateTimePicker in a Excel VSTO floating Add-In and position it so when the calendar drops down, it is outside the edge of the add-in, see here:

enter image description here

Choosing any of the dates circled in the green works as expected, but when clicking any dates circled in red, it just closes the calendar drop down and doesn’t set the date!

Does anyone know how I can fix this?

Edit

This SO user has experienced the problem using WPF:
VSTO WPF ContextMenu.MenuItem Click outside a TaskPane not raised

enter image description here

The answer to that question shows the issue was reported to connect a while back but still no solution with VSTO 4.0 SP1: https://connect.microsoft.com/VisualStudio/feedback/details/432998/excel-2007-vsto-custom-task-pane-with-wpf-context-menu-has-focus-problems

One of the workarounds is to use the DispatcherFrame to pump messages and subscribe to GotFocusEvent and LostFocusEvent for the menu. http://blogs.msdn.com/b/vsod/archive/2009/12/16/excel-2007-wpf-events-are-not-fired-for-items-that-overlap-excel-ui-for-wpf-context-menus.aspx but this is all WPF code for menu’s not a solution for Winform DateTimePicker.

Repro for Microsoft Connect:

New Project > Excel 2010 Add-In

using TaskPane;
using Microsoft.Office.Core;

namespace ExcelAddIn2
{
public partial class ThisAddIn
{
    TaskPaneView MyTaskView = null;
    Microsoft.Office.Tools.CustomTaskPane MyTaskPane = null;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    //setup custom taskpane
    MyTaskView = new TaskPaneView();
    MyTaskView.currentInstance = Globals.ThisAddIn.Application;
    MyTaskPane = this.CustomTaskPanes.Add(MyTaskView, "MyTaskView");
    MyTaskPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionFloating;
    MyTaskPane.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
    MyTaskPane.Visible = true;
}
}

File Menu > Add > New Project > Class Library > named TaskPane

Then in the TaskPane project create a User Control called TaskPaneView

public partial class TaskPaneView : UserControl
{
    public TaskPaneView()
    {
        InitializeComponent();
    }

    public Microsoft.Office.Interop.Excel.Application currentInstance { get; set; }

    public TaskPaneCtrl getTaskPaneCtrl
    {
        get { return this.taskPaneCtrl1; }
    }  

}

Next create a User Control with a DateTimePicker, make sure the Calendar control is located toward the bottom right of the user control

public partial class TaskPaneCtrl : UserControl
{
public TaskPaneCtrl()
{
    InitializeComponent();
}
}

In the TaskPane class library Reference the Excel Interop (eg c:\Program Files x86\Microsoft Visual Studio 14.0\Visual Studio Tools for Office\PIA\Office14\Microsoft.Office.Interop.Excel.dll).

Build the solution. Commenting out parts that dont work. Build Solution.

Now drag and drop the TaskPaneCtrl onto the TaskPaneView and uncomment thing that failed to compile.

enter image description here

F5 and click the Calendar Control, now try to select a date that is outside the taskpane area. No Value Change event fires, it behaves like a click outside the calendar!

Note: I tried a drop downlist that falls off the control but its events DO FIRE!

  • 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. Editorial Team
    Editorial Team
    2026-06-03T15:36:13+00:00Added an answer on June 3, 2026 at 3:36 pm

    “Floating” is the key to the problem here. What’s never not a problem (occasionally responsible for odd things) is relying on the message pump in Excel to dispatch Windows messages, the messages that make these controls respond to input. This goes wrong in WPF as much as Winforms, they have their own dispatch loop that filters messages before they are delivered to the window. Key things that go wrong when their respective dispatcher isn’t used are stuff like tabbing and short-cut keystrokes.

    And then some, this kind of problem would be induced by Excel doing its own filtering before dispatching messages. I’d guess at an anti-malware feature, Microsoft is forever worried about programs messing with Office apps.

    The Winforms solution is the same one as the WPF workaround, you need to pump your own message loop. That requires some surgery, DateTimePicker isn’t going to cooperate since it doesn’t allow its DropDown event to be cancelled and it is raised after the calendar is already shown. The workaround is silly but effective, add a button to your form that looks just like the dropdown arrow on the DTP and make it overlap the arrow so it gets clicked instead of the arrow.

    Some example code for getting the button to overlap the dropdown arrow:

        public Form1() {
            InitializeComponent();
            var btn = new Button();
            btn.BackgroundImage = Properties.Resources.DropdownArrow;
            btn.FlatStyle = FlatStyle.Flat;
            btn.BackColor = Color.FromKnownColor(KnownColor.Window);
            btn.Parent = dateTimePicker1;
            btn.Dock = DockStyle.Right;
            btn.Click += showMonthCalendar;
            dateTimePicker1.Resize += delegate {
                btn.Width = btn.Height = dateTimePicker1.ClientSize.Height;
            };
        }
    

    The Click event handler needs to show a dialog that contains a MonthCalendar:

        private void showMonthCalendar(object sender, EventArgs e) {
            dateTimePicker1.Focus();
            using (var dlg = new CalendarForm()) {
                dlg.DateSelected += new DateRangeEventHandler((s, ea) => dateTimePicker1.Value = ea.Start);
                dlg.Location = dateTimePicker1.PointToScreen(new Point(0, dateTimePicker1.Height));
                dlg.ShowDialog(this);
            }
        }
    

    With CalendarForm a form you add that’s borderless and contains just a MonthCalendar:

    public partial class CalendarForm : Form {
        public event DateRangeEventHandler DateSelected;
    
        public CalendarForm() {
            InitializeComponent();
            this.StartPosition = FormStartPosition.Manual;
            monthCalendar1.Resize += delegate {
                this.ClientSize = monthCalendar1.Size;
            };
            monthCalendar1.DateSelected += monthCalendar1_DateSelected;
        }
    
        void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e) {
            if (DateSelected != null) DateSelected(this, e);
            this.DialogResult = DialogResult.OK;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I thought this was a privilege issue but I logged on as admin and
One of our clients has logged a very strange issue with us- We launched
Have another issue here. Our app starts out with a tab activity. But, before
Does anyone know if a site (even non-Microsoft), that has details on COMExceptions/HRESULTS. When
I've got a similar issue to that reported by another user here XAMPP v1.7.4
Here's the issue. I'm using ASP.NET Forms Authentication for an account balance type website.
I am having the same issue described at this address http://www.cocoabuilder.com/archive/cocoa/288659-iphone-nsmanagedobjectcontext-save-doesn-crash-but-breaks-on-objc-exception-throw.html I am debugging
I'm developing word automation application and I'm facing serious issue with unexpected RPC/COM cast
I have an issue executing a package via the API at Microsoft.SqlServer.Dts.Runtime. I have
The issue here is that when my user logs into my app, they always

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.