When you setup a hierarchical RadVirtualGrid and set the UseScrollbarsInHierarchy property to false and use VirtualGridAutoSizeColumnsMode.Fill for the child template, you expect that the column's width is calculated according to the total width of the respective template. Hence, if you shrink or enlarge the grid, the columns will shrink/enlarge respectively. However, if you double click the resize cursor between the column headers you will notice that the best-fit action is performed over the column and its width is adjusted. However, the VirtualGridAutoSizeColumnsMode.Fill setting is not respected and you either can't see all the columns, or you obtain some empty space if the column doesn't need much space.
To reproduce: if you set the TableElement.RowHeight property, it affects the header row as well, but not all cells. As a result the header row overlaps the new row. Workaround: set the TableElement.HeaderRowHeight as well. this.radVirtualGrid1.TableElement.HeaderRowHeight = 50;
Use attached to reproduce (just start it and press enter). Workaround: class MyBehavior : VirtualGridInputBehavior { public MyBehavior(RadVirtualGridElement element) : base(element) { } protected override bool HandleEnterKey(KeyEventArgs keys) { if (this.GridElement.CurrentCell != null) { return base.HandleEnterKey(keys); } return false; } } radVirtualGrid1.VirtualGridElement.InputBehavior = new MyBehavior(radVirtualGrid1.VirtualGridElement);
Using RadVirtualGrid, I have a requirement for showing hierarchical levels of data. The parent level and child levels share the SAME column headers. I am utilizing the QueryHasChildRows event of the grid to set the number of rows for each hierarchical level. In that event I set a few properties to control how a child view is rendered as below: else if (e.ViewInfo.HierarchyLevel > 0) { var items = ((IList<AllocStructNode>)e.ViewInfo.ParentViewInfo.Tag)[e.ViewInfo.ParentRowIndex]; if (items.Children != null && items.Children.Count > 0) { e.ViewInfo.Tag = items.Children; e.ViewInfo.RowCount = items.Children.Count; e.ViewInfo.HeaderRowHeight = 0; e.ViewInfo.ShowHeaderRow = false; e.ViewInfo.FilterRowHeight = 0; e.ViewInfo.ShowFilterRow = false; e.ViewInfo.Padding = new Padding(0); e.ViewInfo.HorizontalScrollState = ScrollState.AlwaysHide; } } When a new level is rendered, a new demarcated section of child table element with its own horizontal scrolling displayed. When the parent is horizontally scrolled, the child level doesn't scroll (not synchronized). Similarly, when the child is horizontally scrolled, the parent does not scroll as well. Workaround: See attached project.
Please refer to the attached sample project.
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 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
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); }
A newly created grid has its CurrentCell property initialized to Nothing. Pressing [PageDown] or any other key that causes scrolling will crash. Steps to Reproduce: 1. Launch application 2. Press [PageDown] Sub New() InitializeComponent() Me.RadVirtualGrid1.ColumnCount = 50 Me.RadVirtualGrid1.RowCount = 100 AddHandler Me.RadVirtualGrid1.CellValueNeeded, AddressOf RadVirtualGrid1_CellValueNeeded End Sub Private Sub RadVirtualGrid1_CellValueNeeded(sender As Object, e As Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs) e.Value = e.ColumnIndex End Sub Workaround: Me.RadVirtualGrid1.CurrentCell = New Telerik.WinControls.UI.VirtualGridCellInfo(0, 0, Me.RadVirtualGrid1.MasterViewInfo)
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
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.