[Mono-bugs] [Bug 81508][Wis] New - DateTimePicker will cause an NullReferenceException if it is not parented in a form

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue May 1 13:13:32 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by tausq at debian.org.

http://bugzilla.ximian.com/show_bug.cgi?id=81508

--- shadow/81508	2007-05-01 13:13:32.000000000 -0400
+++ shadow/81508.tmp.18355	2007-05-01 13:13:32.000000000 -0400
@@ -0,0 +1,50 @@
+Bug#: 81508
+Product: Mono: Class Libraries
+Version: 1.2
+OS: GNU/Linux [Other]
+OS Details: ubuntu
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Windows.Forms
+AssignedTo: toshok at ximian.com                            
+ReportedBy: tausq at debian.org               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DateTimePicker will cause an NullReferenceException if it is not parented in a form
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+If a DateTimePicker is placed, for example, in a ToolStripControlHost (and
+then placed in a drop down menu), when the DTP is activated, a
+NullReferenceException is generated in:
+System.Windows.Forms.DateTimePicker.CalculateDropDownLocation (Rectangle
+parent_control_rect, Size child_size, Boolean align_left)
+
+Steps to reproduce the problem:
+1. Compile and run attached test program
+2. right click on the form to bring up the menu
+3. open the DateTimePicker's drop down 
+
+Actual Results:
+App dies with NullReferenceException
+
+Expected Results:
+Calendar should be shown below the menu
+
+How often does this happen? 
+Always reproducible
+
+Additional Information:
+The problem arises because in this case the DTP is contained in a
+ToolStripControlHost (which is not a form or even a control), so the DTP
+control's Parent is null.
+
+In this case, at the end of CalculateDropDownLocation(), the logic to
+adjust the location of the drop down calendar based on the parent form
+generates the null reference. A simple null check before the
+PointToClient() call will fix the problem.


More information about the mono-bugs mailing list