To reproduce: private void RadVirtualGrid1_EditorRequired(object sender, Telerik.WinControls.UI.VirtualGridEditorRequiredEventArgs e) { switch (e.ColumnIndex) { case 1: { VirtualGridTextBoxControlEditor editor = new VirtualGridTextBoxControlEditor(); editor.CharacterCasing = CharacterCasing.Upper; e.Editor = editor; } break; } } - Open the editor and try using the backspace or the arrow keys. Workaround: class MyGrid : RadVirtualGrid { protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (this.ActiveEditor is VirtualGridTextBoxControlEditor) { var editor = this.ActiveEditor as VirtualGridTextBoxControlEditor; var element = editor.EditorElement as RadTextBoxControlElement; element.InputHandler.ProcessKeyDown(e); } } protected override void OnKeyUp(KeyEventArgs e) { base.OnKeyUp(e); if (this.ActiveEditor is VirtualGridTextBoxControlEditor) { var editor = this.ActiveEditor as VirtualGridTextBoxControlEditor; var element = editor.EditorElement as RadTextBoxControlElement; element.InputHandler.ProcessKeyUp(e); } } }
To reproduce: use the following code snippet and follow the steps: public RadForm1() { InitializeComponent(); this.radVirtualGrid1.RowCount = 10; this.radVirtualGrid1.ColumnCount = 5; this.radVirtualGrid1.CellValueNeeded+=radVirtualGrid1_CellValueNeeded; } private void radVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e) { e.Value = e.RowIndex + "." + e.ColumnIndex; } 1. Pin (left or right) 1st column 2. Scroll horizontally (to not display 2nd column) 3. Unpin 1st column 4. Scroll horizontally to display 1st column => 1st column is hidden, the only way to make it visible is to resize a column or the entire window Workaround: private void radVirtualGrid1_ContextMenuOpening(object sender, Telerik.WinControls.UI.VirtualGridContextMenuOpeningEventArgs e) { foreach (RadItem item in e.ContextMenu.Items) { if (item.Text == RadVirtualGridLocalizationProvider.CurrentProvider.GetLocalizedString(RadVirtualGridStringId.PinMenuItem)) { foreach (RadMenuItem subItem in ((RadMenuItem)item).Items) { if (subItem.Text == RadVirtualGridLocalizationProvider.CurrentProvider.GetLocalizedString(RadVirtualGridStringId.UnpinColumnMenuItem)) { subItem.Click-=subItem_Click; subItem.Click+=subItem_Click; } } } } } private void subItem_Click(object sender, EventArgs e) { this.radVirtualGrid1.MasterViewInfo.SetColumnWidth(0, this.radVirtualGrid1.MasterViewInfo.GetColumnWidth(0)); }
To reproduce: - Open the attached project. - Unselect Column3 from the list. Workaround: this.radVirtualGrid1.MasterViewInfo.CustomColumns.RemoveAt(0); foreach (VirtualGridRowElement rowElement in this.radVirtualGrid1.VirtualGridElement.TableElement.GetDescendants(delegate(RadElement x) { return x is VirtualGridRowElement; }, TreeTraversalMode.BreadthFirst)) { rowElement.CellContainer.Children.Clear(); }
To reproduce: - Change the editor to VirtualGridDropDownListEditor - Press alpha-numeric key when the grid is not in edit mode. Workaround: radVirtualGrid1.VirtualGridElement.InputBehavior = new MyBehavior(radVirtualGrid1.VirtualGridElement); class MyBehavior : VirtualGridInputBehavior { public MyBehavior(RadVirtualGridElement element) : base(element) { } protected override bool HandleAlphaNumericKey(KeyPressEventArgs keys) { if (!this.GridElement.IsInEditMode && (this.GridElement.BeginEditMode == RadVirtualGridBeginEditMode.BeginEditOnKeystroke || this.GridElement.BeginEditMode == RadVirtualGridBeginEditMode.BeginEditOnKeystrokeOrF2)) { //this.GridElement.HideContextMenu(); this.GridElement.BeginEdit(); if (this.GridElement.ActiveEditor is VirtualGridDropDownListEditor) { string symbol = keys.KeyChar.ToString(); var editor = this.GridElement.ActiveEditor as VirtualGridDropDownListEditor; var element = editor.EditorElement as RadDropDownListEditorElement; if ((element.AutoCompleteMode & AutoCompleteMode.Append) == AutoCompleteMode.Append) { int index = element.AutoCompleteAppend.FindShortestString(symbol); if (index == -1) { element.EditableElementText = symbol; element.EditableElement.SelectionStart = 1; element.EditableElement.SelectionLength = 0; return true; } } } return false; } return base.HandleAlphaNumericKey(keys); } }
To reproduce: use the following code snippet and try to select another cell. public RadForm1() { InitializeComponent(); this.radVirtualGrid1.RowCount = 30; this.radVirtualGrid1.ColumnCount = 5; this.radVirtualGrid1.CellValueNeeded += radVirtualGrid1_CellValueNeeded; this.radVirtualGrid1.CurrentCellChanging += radVirtualGrid1_CurrentCellChanging; } private void radVirtualGrid1_CurrentCellChanging(object sender, Telerik.WinControls.UI.VirtualGridCellInfoCancelEventArgs e) { e.Cancel = true; } private void radVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e) { e.Value = e.RowIndex + "." + e.ColumnIndex; } Workaround: public class CustomVirtualGrid : RadVirtualGrid { public override string ThemeClassName { get { return typeof(RadVirtualGrid).FullName; } } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { return; } base.OnMouseDown(e); } }
To reproduce: public Form1() { InitializeComponent(); this.radVirtualGrid1.ColumnCount = 5; this.radVirtualGrid1.RowCount = 20; this.radVirtualGrid1.CellValueNeeded += radVirtualGrid1_CellValueNeeded; } private void radVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e) { e.Value = "Data" + e.RowIndex + "." + e.ColumnIndex; } Workaround: use a custom ScrollableVirtualCellsContainer: public Form1() { InitializeComponent(); this.radVirtualGrid1.CreateRowElement += radVirtualGrid1_CreateRowElement; this.radVirtualGrid1.ColumnCount = 5; this.radVirtualGrid1.RowCount = 20; this.radVirtualGrid1.CellValueNeeded += radVirtualGrid1_CellValueNeeded; } private void radVirtualGrid1_CreateRowElement(object sender, VirtualGridCreateRowEventArgs e) { e.RowElement = new CustomVirtualGridRowElement(); } private void radVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e) { e.Value = "Data" + e.RowIndex + "." + e.ColumnIndex; } public class CustomVirtualGridRowElement : VirtualGridRowElement { public CustomVirtualGridRowElement() : base() { FieldInfo fi = typeof(VirtualGridRowElement).GetField("scrollableColumns", BindingFlags.NonPublic | BindingFlags.Instance); ScrollableVirtualCellsContainer scrollableColumns = fi.GetValue(this) as ScrollableVirtualCellsContainer; CustomScrollableVirtualCellsContainer newScrollableColumns = new CustomScrollableVirtualCellsContainer(); FieldInfo fi2 = typeof(ScrollableVirtualCellsContainer).GetField("rowElement", BindingFlags.NonPublic | BindingFlags.Instance); fi2.SetValue(newScrollableColumns, this); this.Children.Remove(scrollableColumns); this.Children.Insert(1, newScrollableColumns); } } public class CustomScrollableVirtualCellsContainer : ScrollableVirtualCellsContainer { protected override SizeF MeasureElementCore(RadElement element, SizeF availableSize) { int scrollOffset = 0; if (this.RowElement.TableElement.ColumnScroller.ScrollMode == ItemScrollerScrollModes.Discrete) { for (int i = 0; i < this.RowElement.TableElement.ColumnScroller.Scrollbar.Value; i++) { scrollOffset += this.RowElement.TableElement.ColumnScroller.GetScrollHeight( this.RowElement.TableElement.ViewInfo.ColumnsViewState.GetItemSize(i)); } } else { scrollOffset = this.RowElement.TableElement.HScrollBar.Value; } VirtualGridCellElement cellElement = element as VirtualGridCellElement; int itemOffset = this.RowElement.ViewInfo.ColumnsViewState.GetItemOffset(cellElement.Data); int itemWidth = this.RowElement.ViewInfo.ColumnsViewState.GetItemSize(cellElement.Data); element.Measure(availableSize); if (itemOffset + itemWidth > scrollOffset && itemOffset < scrollOffset) { return new SizeF((itemOffset + itemWidth) - scrollOffset, element.DesiredSize.Height); } return element.DesiredSize; } }
To reproduce: - Subscribe to the SelectionChanged event. - Move the mouse while holding the left button. - The event is fire multiple times. Workaround: VirtualGridCellInfo prevCell = null; private void OnGridSelectionChanged(object sender, EventArgs e) { if (prevCell != gvItems.CurrentCell) { _selectionChangedCount++; tbLog.AppendText("Selection changed " + _selectionChangedCount + "\r\n"); } prevCell = gvItems.CurrentCell; }
Please refer to the attached sample project.
To reproduce: public RadForm1() { InitializeComponent(); radVirtualGrid1.CellValueNeeded += RadVirtualGrid1_CellValueNeeded; radVirtualGrid1.ColumnCount = 20; radVirtualGrid1.RowCount = 1000; radVirtualGrid1.AutoSizeColumnsMode = Telerik.WinControls.UI.VirtualGridAutoSizeColumnsMode.Fill; } private void RadVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e) { e.Value = string.Format("Col {0} Row{1}", e.ColumnIndex, e.RowIndex); } - Press and hold the down key, you will notice that the selection freezes after some time and is updated after the key is released.
To reproduce: public RadForm1() { InitializeComponent(); radVirtualGrid1.CellValueNeeded += RadVirtualGrid1_CellValueNeeded; radVirtualGrid1.ColumnCount = 100; radVirtualGrid1.RowCount = 50; radVirtualGrid1.AutoSizeColumnsMode = Telerik.WinControls.UI.VirtualGridAutoSizeColumnsMode.Fill; radVirtualGrid1.SelectionMode = Telerik.WinControls.UI.VirtualGridSelectionMode.CellSelect; } private void RadVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e) { e.Value = string.Format("Col {0} Row{1}", e.ColumnIndex, e.RowIndex); }
Please refer to the attached gif file demonstrating how to reproduce the issue with the Demo application. Workaround: Public Class Form1 Sub New() InitializeComponent() Me.RadVirtualGrid1.AllowAddNewRow = False Me.RadVirtualGrid1.AllowFiltering = False Me.RadVirtualGrid1.ColumnCount = 5 Me.RadVirtualGrid1.MasterViewInfo.RegisterCustomColumn(3) Me.RadVirtualGrid1.RowCount = 1 End Sub Private Sub RadVirtualGrid1_CreateCellElement(sender As Object, e As VirtualGridCreateCellEventArgs) Handles RadVirtualGrid1.CreateCellElement Dim columnIndex As Integer = e.ColumnIndex If e.ViewInfo.ColumnsViewState.TopPinnedItems.Count > 0 AndAlso e.ColumnIndex - 1 < e.ViewInfo.ColumnsViewState.TopPinnedItems.Count Then columnIndex = e.ViewInfo.ColumnsViewState.TopPinnedItems(e.ColumnIndex - 1) End If If columnIndex = 3 AndAlso e.RowIndex >= 0 Then e.CellElement = New RedCellElement() End If End Sub Private Sub RadVirtualGrid1_CellValueNeeded(sender As Object, e As VirtualGridCellValueNeededEventArgs) Handles RadVirtualGrid1.CellValueNeeded e.Value = String.Format("{0}x{1}", e.RowIndex, e.ColumnIndex) End Sub End Class Class RedCellElement Inherits VirtualGridCellElement Sub New() MyBase.New() End Sub Private checkBox As RadCheckBoxElement Protected Overrides Sub CreateChildElements() MyBase.CreateChildElements() Me.checkBox = New RadCheckBoxElement() Me.Children.Add(Me.checkBox) End Sub Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(VirtualGridCellElement) End Get End Property Public Overrides Function IsCompatible(data As Integer, context As Object) As Boolean Dim headerRow As VirtualGridHeaderRowElement = TryCast(context, VirtualGridHeaderRowElement) If data >= 3 AndAlso headerRow Is Nothing Then Return True Else Return False End If End Function Protected Overrides Sub UpdateInfo(args As VirtualGridCellValueNeededEventArgs) MyBase.UpdateInfo(args) Me.NumberOfColors = 1 Me.DrawFill = True Me.BackColor = Color.Red End Sub End Class
When a row/column is resized, and we scroll to the last row/column, they are cut off, due to an error in the item spacing calculation To reproduce: radVirtualGrid1.RowCount = 1000; radVirtualGrid1.ColumnCount = 50; radVirtualGrid1.MasterViewInfo.SetRowHeight(50, 30); for (int i = 0; i < 50; i++) { radVirtualGrid1.MasterViewInfo.SetColumnWidth(i, 60); } void radVirtualGrid1_CellValueNeeded(object sender, VirtualGridCellValueNeededEventArgs e) { e.Value = e.RowIndex + " " + e.ColumnIndex; } Workaround: set the RadVirtualGrid.TableElement.ColumnWidth property to 60 instead of using the SetColumnWidth method and set the radVirtualGrid1.MasterViewInfo.RowSpacing to 0 to overcome the row issue.
Description When the RowCount/ColumnCount amount is decreased, and there are resized rows/column, the scrollable area get invalid. Steps to reproduce: RadVirtualGrid radVirtualGrid1 = new RadVirtualGrid(); public Form1() { InitializeComponent(); radVirtualGrid1.Parent = this; radVirtualGrid1.Dock = DockStyle.Fill; this.Controls.SetChildIndex(radVirtualGrid1, 0); button1.BringToFront(); radVirtualGrid1.RowCount = 1000; radVirtualGrid1.ColumnCount = 50; radVirtualGrid1.CellValueNeeded += radVirtualGrid1_CellValueNeeded; for (int i = 0; i < 50; i++) { radVirtualGrid1.MasterViewInfo.SetRowHeight(i, 30); radVirtualGrid1.MasterViewInfo.SetColumnWidth(i, 60); } } void radVirtualGrid1_CellValueNeeded(object sender, VirtualGridCellValueNeededEventArgs e) { e.Value = e.RowIndex + " " + e.ColumnIndex; } private void button1_Click(object sender, EventArgs e) { radVirtualGrid1.RowCount = 20; radVirtualGrid1.ColumnCount = 20; }
To reproduce: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.RadVirtualGrid1.SelectionMode = Telerik.WinControls.UI.VirtualGridSelectionMode.CellSelect Me.RadVirtualGrid1.MultiSelect = True Me.RadVirtualGrid1.RowCount = 10 Me.RadVirtualGrid1.ColumnCount = 5 Me.RadVirtualGrid1.SelectAll() Debug.Assert(Me.RadVirtualGrid1.Selection.MaxColumnIndex = Me.RadVirtualGrid1.ColumnCount - 1) Debug.Assert(Me.RadVirtualGrid1.Selection.MaxRowIndex = Me.RadVirtualGrid1.RowCount - 1) End Sub End Class Workaround: Private Sub RadVirtualGrid1_SelectionChanging(ByVal sender As Object, ByVal e As VirtualGridSelectionChangingEventArgs) If e.SelectionAction = VirtualGridSelectionAction.SelectAll Then e.Cancel = True radVirtualGrid1.VirtualGridElement.Selection.BeginSelection(0,0, radVirtualGrid1.MasterViewInfo, False) radVirtualGrid1.VirtualGridElement.Selection.ExtendCurrentRegion(radVirtualGrid1.RowCount-1,radVirtualGrid1.ColumnCount -1) End If End Sub
To reproduce: 1. Select multiple cells in RadVirtualGrid 2. Right-click one of the selected cells. The expected behavior is to open the context menu in order to allow copy operation and keep the selected cells. However, the obtained result is that the selected cells are cleared. Workaround: Me.RadVirtualGrid1.VirtualGridElement.InputBehavior = New CustoVirtualGridInputBehavior(Me.RadVirtualGrid1.VirtualGridElement) AddHandler Me.RadVirtualGrid1.SelectionChanging, AddressOf SelectionChanging Private Sub SelectionChanging(sender As Object, e As Telerik.WinControls.UI.VirtualGridSelectionChangingEventArgs) If Me.RadVirtualGrid1.VirtualGridElement.Tag = "CancelSelectionChange" Then e.Cancel = True Me.RadVirtualGrid1.VirtualGridElement.Tag = Nothing End If End Sub Public Class CustoVirtualGridInputBehavior Inherits VirtualGridInputBehavior Public Sub New(gridElement As RadVirtualGridElement) MyBase.New(gridElement) End Sub Public Overrides Function HandleMouseDown(args As MouseEventArgs) As Boolean If args.Button = MouseButtons.Right Then Dim cell As VirtualGridCellElement = TryCast(Me.GridElement.ElementTree.GetElementAtPoint(args.Location), VirtualGridCellElement) If cell IsNot Nothing AndAlso cell.IsSelected Then Me.GridElement.Tag = "CancelSelectionChange" End If End If Return MyBase.HandleMouseDown(args) End Function End Class