|
To achieve multiple selection using Shift key instead of control key, you need to access the GridControl from the MonthCalendarAdv control. Then you need to handle GridCellClick event and add selected cells in Selections list of the grid. Please refer to the following code snippet. C# public void SetUpMonthCalendar(MonthCalendarAdv ctrlMonthAdv) { ctrlMonthAdv.AllowMultipleSelection = false; foreach (Control ctl1 in ctrlMonthAdv.Controls) { GridControl _crlGrid = ctl1 as GridControl; if (_crlGrid != null) { _crlGrid.Focus(); _crlGrid.MouseDown += new MouseEventHandler(GridMouseDownForSelection); _crlGrid.PrepareChangeSelection += new GridPrepareChangeSelectionEventHandler(_crlGrid_PrepareChangeSelection); _crlGrid.PrepareClearSelection += new EventHandler(_crlGrid_PrepareClearSelection); _crlGrid.AllowSelection = GridSelectionFlags.AlphaBlend | GridSelectionFlags.Shift; _crlGrid.MouseMove += new MouseEventHandler(_crlGrid_MouseMove); _crlGrid.CellClick += new GridCellClickEventHandler(_crlGrid_CellClick); break; } } } void _crlGrid_CellClick(object sender, GridCellClickEventArgs e) { GridControl _crlGrid = sender as GridControl; if (Control.ModifierKeys == Keys.Shift) { GridRangeInfo range = _crlGrid.CurrentCell.RangeInfo; if (IsFirstClick) { range = GridRangeInfo.Cell(FirstRowIndex, FirstColIndex); IsFirstClick = false; } int row, col; if (_crlGrid.PointToRowCol(e.MouseEventArgs.Location, out row, out col)) { _crlGrid.Model.Selections.Add(GridRangeInfo.Cells(range.Top, range.Left, row, col)); } _crlGrid.Refresh(); } } VB Public Sub SetUpMonthCalendar(ByVal ctrlMonthAdv As Syncfusion.Windows.Forms.Tools.MonthCalendarAdv) ctrlMonthAdv.AllowMultipleSelection = False For Each ctl1 As Control In ctrlMonthAdv.Controls Dim _crlGrid As Syncfusion.Windows.Forms.Grid.GridControl = CType(IIf(TypeOf ctl1 Is Syncfusion.Windows.Forms.Grid.GridControl, ctl1, Nothing), Syncfusion.Windows.Forms.Grid.GridControl) If Not _crlGrid Is Nothing Then _crlGrid.Focus() _crlGrid.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.AlphaBlend Or Syncfusion.Windows.Forms.Grid.GridSelectionFlags.Shift AddHandler _crlGrid.MouseMove, AddressOf _crlGrid_MouseMove AddHandler _crlGrid.CellClick, AddressOf _crlGrid_CellClick Exit For End If Next ctl1 End Sub Private Sub _crlGrid_CellClick(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs) Dim _crlGrid As Syncfusion.Windows.Forms.Grid.GridControl = CType(IIf(TypeOf sender Is Syncfusion.Windows.Forms.Grid.GridControl, sender, Nothing), Syncfusion.Windows.Forms.Grid.GridControl) If Control.ModifierKeys = Keys.Shift Then Dim range As Syncfusion.Windows.Forms.Grid.GridRangeInfo = _crlGrid.CurrentCell.RangeInfo If IsFirstClick Then range = Syncfusion.Windows.Forms.Grid.GridRangeInfo.Cell(FirstRowIndex, FirstColIndex) IsFirstClick = False End If Dim row, col As Integer If _crlGrid.PointToRowCol(e.MouseEventArgs.Location, row, col) Then _crlGrid.Model.Selections.Add(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Cells(range.Top, range.Left, row, col)) End If _crlGrid.Refresh() End If End Sub Here is the sample http://websamples.syncfusion.com/samples/KB/Tools.Windows/MultipleSelection_in_Calender/main.htm |