We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MonthCalendarAdv - Get date for cell, select cell by date?

Thread ID:

Created:

Updated:

Platform:

Replies:

97625 Dec 18,2010 08:01 PM UTC Jan 20,2011 11:16 PM UTC Windows Forms 5
loading
Tags: Tools
Joel McIntyre
Asked On December 18, 2010 08:01 PM UTC

I'm investigating using the MonthCalendarAdv control to display color statuses for each date in my app.

I read the documentation, and read through the public members, but haven't found what I'm looking for.

Using GetCellInfo(...) and SetCellInfo(...) I can retrieve and alter a day's appearance, but I don't see a way to do the following. Please help!

1) I can't tell directly "which date" a cell is, i.e. GetCellInfo(1,1)'s date.

2) I really don't care where a cell is, is there a way to go directly from the date to getting/setting that cell's info, or at least get the cell row and column from a date?

Part of all that is I want to let the user customize what the first day of the week shown is - Sunday, Monday, whatever day the 1st is..., and I'd rather not be writing my own conversion routine of date <-> cell location if there is one built in that I've missed.

Thanks for any assistance, and sorry if I just missed it in the documentation - please point me to it!

Best Wishes,
Joel



Vallarasu S [Syncfusion]
Replied On December 20, 2010 01:01 PM UTC

Hi Joel,

Thanks for your interest in Syncfusion products.

You can get information on a particular cell via DateCellQueryInfo event, it provides row and column index as well. MonthCalendarAdv supports changing the first day of week through FirstDayOfWeek property. Refer the following documentations for further information.

DateCellQueryInfo_Event

FirstDayOfWeek_Property

Please let us know if you need any further information in this regard.

Regards
Vallarasu S.



Joel McIntyre
Replied On December 20, 2010 03:52 PM UTC

Thanks for taking a look!

Maybe I'm missing something; DateCellQueryInfo is a callback when the user interacts with the control? I'm not sure how to trigger that I want cell 3,3 to "perform DateCellQueryInfo callback".

Or am I supposed to refresh all the days if I need to change one? I'm not sure the scenario you guys have in mind.

My general scenario: customers call phone operators, who put a past date (usually in the last month) in the database with a research question. Level 1 support people have an app that watches the database, and colors the calendar days with 'work to be done' or 'all resolved'.

When I load a new date from the database, I'm having trouble converting 12/15/2010 to a column & row (or searching the grid for the right date) so that I can call SetCellInfo and change the background color.

I'm unclear how DateCellQueryInfo helps me? The calendar doesn't know to make the callback? Or do I invalidate the whole calendar and let it cycle through every date?

Thanks!
Joel


Iniyen M A [Syncfusion]
Replied On December 31, 2010 04:08 AM UTC

Hi Joel,

Thanks for the update.

You can achieve your requirements by using DateCellQueryInfo event. This event uses ‘DateValue’ object which is used to specify the date value by converting DateTime to DateValue and finding the match of the specific date, month, year as your requirement. For your information the code is as follows.


this.monthCalendarAdv1.DateCellQueryInfo +=new Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventHandler(monthCalendarAdv1_DateCellQueryInfo);
private void monthCalendarAdv1_DateCellQueryInfo(object sender, Syncfusion.Windows.Forms.Tools.DateCellQueryInfoEventArgs e)
{
if (e.DateValue != null)
{
DateTime dt = (DateTime)e.DateValue;

if (new DateTime(dt.Year, dt.Month, dt.Day) == new System.DateTime(2010, 11, 15))
{
e.Style.BackColor = Color.Green;

}
}
}


Please let us know if you have any concerns in this.

Regards,
Iniyen M.A.


Joel McIntyre
Replied On January 10, 2011 07:23 PM UTC

"Refresh()"

I figured out what I was missing!

I need to call monthCalendarAdv1.Refresh(), and it will call monthCalendarAdv1_DateCellQueryInfo() so I can update my colors.

I had tried both Invalidate() and RefreshCalendar() with no luck, but if I store the "date colors" in my app and use that list in DateCellQueryInfo(), I can force the UI to update by calling Refresh(), which calls the necessary DateCellQueryInfo().


(By the way, it looks like SetCellInfo(...) and GetCellInfo(...) aren't available like I thought they were - maybe it's only in 4.0 and not 3.5? I'm not certain, but I saw them in initial testing and don't see them now.)

As a feature request, would you consider in future releases adding a way to convert a date to or from a cell, like:

----

Point cell = monthCalendarAdv1.DateToCell(datetime);
DateTime date = monthCalendarAdv1.CellToDate(3 ,2);

----

other alternatives might be extending SetCellInfo to take a date rather than a row/column pair:
SetCellInfo(datetime, cellinfo);

and of course GetCellInfo() should return the cell's date somehow as part of the details.

----

Thanks for the help! I've got some more questions, but I'll start new threads for those.

-Joel


Jeraldes J [Syncfusion]
Replied On January 20, 2011 11:16 PM UTC

Hi Joel,

Thanks for yoour update.

Please let us know if you need any more details.

Regards,
J Jeraldes


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;