ajithev
August 24th, 2009, 12:11 AM
plz help me to find the position of a date in calendar control
|
Click to See Complete Forum and Search --> : how to find the position of date in c# ajithev August 24th, 2009, 12:11 AM plz help me to find the position of a date in calendar control rliq August 24th, 2009, 12:22 AM There have already been quite a few dates in the past and many more are hoped for many more in the future. Could you be a bit more specific as to which one of these dates you mean please and what you mean by 'position'... For example: Do you mean the x,y (Location) coordinates of the currently selected (highlighted) date in a Calander Control? or Do you mean the x,y (Location) coordinates of the dd/mm/yyyy string at the bottom of a Calander Control? or Do you simply mean the DateTime version of the currently selected date? Also, bear in mind that there could be many selected dates... ajithev August 24th, 2009, 12:47 AM im looking for the x,y (Location) coordinates of the currently selected (highlighted) date in a Calander Control rliq August 24th, 2009, 01:05 AM Get the SelectedRange property. Assume the first one is the date we are after. Using the current month and taking into account the FirstDayOf Week property, calculate the logical row and column the selected date would be in (it's Aug 24th 2009 here in Australia at the moment), so that is column 0, row 4. Scale the 0 and 4 to the size of the actual calander control, which is a constant of 203, 155, using the total number of rows and columns, don't forget to check if the ShowWeekNumbers property is set to true as this will add an extra column on at the left. Add the height of the header (eg "August 2009"), measure this with a pixel ruler, to the scaled row and Bob's your uncle.... ummm seems you would have to take the CalanderDimensions property into account too... good luck with this one... I don't think the calander control was designed for this purpose, can you explain why you want to use it that way, as there maybe a better solution. rliq August 24th, 2009, 01:10 AM Alternatively, assuming the user has clicked the mouse to select the date, you maybe able to catch the Mouse x,y which may help zoom in on the location quicker. ajithev August 24th, 2009, 01:36 AM if i take the mouse position the problem is if i click on month header it gives me a different location but when i try to extract the date from that position i get selected date itself since the function getdateatpoint () returns selected date if any else only it returns according to the mouse(x,y) location rliq August 24th, 2009, 01:43 AM May I ask again, what is the reason for doing this? ajithev August 24th, 2009, 01:51 AM this is one of my test project. rliq August 24th, 2009, 01:55 AM If it's something you have to do, then my 2nd post will be the way to go. But I'm not sure if this will help develop your software skillls. ajithev August 24th, 2009, 02:15 AM thank you. if i get any idea ill reply in this thread albuquerque September 3rd, 2009, 09:12 PM Hi all, I am new to .net, c#. I need the x,y position of selected date, because I want a model extender popup at that position. If anybody has code snippet or any ideas. Please help me. Regards, Alb rliq September 4th, 2009, 01:55 AM Assumptions.... There is a form with a MonthCalendar control on it. Name is mc. *IMPORTANT*, the first day of the week property has been changed to Sunday (from the default of Monday). There are two Label controls on it lblX and lblY. The header (blue area is 2 units high, the day header and all weeks are 1 unit high and the footer (date) is 1 unit high. The following code gives you the top-left coordinate of the selected date in response to a DataChanged event. Off to TechED Australia now, have a great week everyone... private void mc_DateChanged(object sender, DateRangeEventArgs e) { // get the selected date DateTime date = e.Start; // get the x-coord (width is 7 days) float x = (float)date.DayOfWeek * (float)mc.Width / 7.0f; // get the first day of the month DateTime startOfMonth = new DateTime(date.Year, date.Month, 1); // calculate which week of the month it is in, from 0 to 4 Int32 week = ((Int32)startOfMonth.DayOfWeek + (Int32)date.Day - 1) / 7; // offset of 3 units to cover the headers, total of 10 units high float y = (3.0f + (float)week) * (float)mc.Height / 10.0f; // display the x,y lblX.Text = x.ToString(); lblY.Text = y.ToString(); } I did limited testing, but may be a shot in the right direction... albuquerque September 4th, 2009, 01:40 PM Hi Rliq, Thanks for immediate response. But I dont know what is a monthcalendar control. I have a webform with 12 calendar controls, one for each month, when user select a date, I want a modal popup extender with some radio buttons will show up, when user select an option I have to add that info to that cell in calendar. How can I make the popup show at the selected position? How to add that selected info to that cell? I found we can do this only in DayRender event, but how can I make DayRender event fire after selecting the option from modal popup? If user select another date from the same month, calendar has to show selected infromation for both dates. Regards, Alb albuquerque September 9th, 2009, 10:23 PM Hi Rliq, I need to put a background image for calendar cell, if there is an event on that date. I know how to add image to the calendar cell, but i want to set a background image for the cell. I need it very urgently, Anyone please help me. Regards, ALb rliq September 13th, 2009, 10:57 PM I'm a bit confused. What is the type of control that you are using? Please give the exact definition of the type. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |