Click here to Skip to main content
15,885,903 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I copied-and-pasted all the controls on a form to another to ease the process of creating a new app based on the look and feel of the exiting one. Included in the copied controls were two MonthCalandars. Their AllowDrop and Enabled properties are true. They only contain one event, for the DateSelected event, and the code is identical:

C#
private void monthCalendarBegin_DateSelected(object sender, DateRangeEventArgs e)
{
    beginDateText.Text = monthCalendarBegin.SelectionStart.ToShortDateString();
    monthCalendarBegin.Visible = false;
}


However, in the original app, clicking monthCalendarBegin (and monthCalendarEnd) cause/allow the MonthCalendars to drop down; in the new app, they do not. There is no err msg, they simply don't drop.

I compared all the property settings, and they are identical; what could be causing this?
Posted
Comments
BillWoodruff 29-Oct-15 14:52pm    
Very unlikely, but: is there any difference in: the versions of the controls you copy-paste and the same controls on the toolpalette in the version of Visual Studio you paste into ? difference in the Visual Studio versions being used; any difference in .NET FrameWork versions used here ? If you start a new WinForm Project, and copy-paste the two MonthCalendars into a Form, same behavior ?

I'd certainly want to inspect the Designer.cs code for the two Controls to see if anything "strange" shows up.
B. Clay Shannon 29-Oct-15 14:59pm    
Yes, I checked both the *.cs and the *.designer.cs, with nothing different (even the name is the same). Both are VS 2013, and I copy-pasted the controls from one form to the other. The MonthCalendars *will* drop down when the associated TextBox is clicked (due to code that does that: monthCalendarBegin.Visible = true;), but there is no "click" event for the MonthCalendar controls themselves.
George Jonsson 29-Oct-15 18:50pm    
I have had similar problems when copying controls, but the cause has always been that I have forgotten to attach the event in the design file as this is not done automatically.
Can you show the relevant code for the design of monthCalendarBegin?
B. Clay Shannon 29-Oct-15 19:00pm    
Thanks, but the only event is DateSelected, and that has been added, too. It is very odd; the code seems just the same, yet the two projects behave differently in that respect.
George Jonsson 29-Oct-15 19:04pm    
OK, then you indeed have a weird problem.
What if you add a new MonthCalendar as a test and see if that one drops down.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900