This is a migrated thread and some comments may be shown as answers.

select multiple columns

1 Answer 59 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
mohammadreza
Top achievements
Rank 1
mohammadreza asked on 18 May 2016, 07:10 AM

Hi...

I use UI for winforms Q3 2013... I have a radcalendar on my form, what I wanna accomplish is to select more than one column at a time... I setted the allowmultiselect propery to true but didn't help. it even deselects other selectedDays wich i select with normal mouseclick when any column header is clicked... is there any way to select multiple columns as well as selecting any cell by click without deselecting other dates at a time?

thanks...

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 18 May 2016, 12:23 PM
Hi Mohammadreza,

Thank you for writing.

Clicking the column header selects all cells and selects the entire column, this is the default behaviour and it cannot be changed. 

What you can do is manually select the cells when a particular cell is clicked, you will have to disable the default functionality as well. For example:
bool canSelect = false;
private void Calendar_MouseDown(object sender, MouseEventArgs e)
{
    var clickedCell = calendar.ElementTree.GetElementAtPoint(e.Location) as CalendarCellElement;
    if (clickedCell != null)
    {
        bool isHeader = (bool)clickedCell.GetValue(CalendarCellElement.IsHeaderCellProperty);
        if (isHeader)
        {
            canSelect = true;
            foreach (CalendarCellElement item in ((MonthViewElement)calendar.CalendarElement.CalendarVisualElement).TableElement.Children)
            {
                if (item.Column == clickedCell.Column)
                {
                    item.Selected = true;
                }
            }
            canSelect = false;
        }
    }
}
 
private void Calendar_SelectionChanging(object sender, SelectionEventArgs e)
{
    e.Cancel = !canSelect;
}

I hope this will be useful. 

Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
mohammadreza
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or