Help me to develop cool date picker.[Windows]
-
I want to develop a date picker control which will have cool look-n-feel. My control will be derived from “System.Windows.Forms.Control”.On click event I am trying to show the form which has to “Monthcalendar” control. The problem is the form will not display at the correct position. Help me to determine the position to display the form to get exact appearance of the Windows date picker.
M.Sendilkumar,Bangalore,India.
-
I want to develop a date picker control which will have cool look-n-feel. My control will be derived from “System.Windows.Forms.Control”.On click event I am trying to show the form which has to “Monthcalendar” control. The problem is the form will not display at the correct position. Help me to determine the position to display the form to get exact appearance of the Windows date picker.
M.Sendilkumar,Bangalore,India.
Well, need I say that if you're having trouble positioning the form, writing it may be an issue, too ? You show the form relative to the button, work out how you want it to show relative to the button, and set it's position from the button location.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Well, need I say that if you're having trouble positioning the form, writing it may be an issue, too ? You show the form relative to the button, work out how you want it to show relative to the button, and set it's position from the button location.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Thats what my problem is.I Set the button's left as form's left and button's top+buttons'height as form's top. This is the logic.
protected override void OnClick(EventArgs e) { SetAutoLocation(); frmCal.Show(); Invalidate(); } private void SetAutoLocation() { Rect rect; GetWindowRect(this.Handle, out rect); Point tergatePoint; tergatePoint = new Point(rect.left, rect.top + this.Height); tergatePoint = new Point(Left, Top + Height); if (rect.left + this.Width - frmCal.Width < 0) { tergatePoint.X = 0; } else { tergatePoint.X = rect.left - frmCal.Width + this.Width; } if (tergatePoint.X + frmCal.Width > System.Windows.Forms.SystemInformation.WorkingArea.Right) { tergatePoint.X = System.Windows.Forms.SystemInformation.WorkingArea.Right - frmCal.Width; } else if (tergatePoint.X < 0) tergatePoint.X = 0; if (tergatePoint.Y + frmCal.Height > System.Windows.Forms.SystemInformation.WorkingArea.Bottom) { tergatePoint.Y = rect.top - frmCal.Height; } if (tergatePoint.Y < 0) { tergatePoint.Y = 0; } if (tergatePoint.X < 0) { tergatePoint.X = 0; } frmCal.Location = tergatePoint; } public struct Rect { internal int left, top, right, bottom; }
First click form is not positioning well ,but from second click onwards it is working fine. Can you just see that logic is correct or not?
M.Sendilkumar