select multiple columns

2 posts, 1 answers
  1. mohammadreza
    mohammadreza avatar
    1 posts
    Member since:
    May 2016

    Posted 18 May 2016 Link to this post

    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...

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1822 posts

    Posted 18 May 2016 Link to this post

    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.
Back to Top