To reproduce: - Enable the paging and add 1000 rows. - Press Ctrl + End - An exception is thrown. Workaround: radVirtualGrid1.VirtualGridElement.InputBehavior = new MyBehavior(radVirtualGrid1.VirtualGridElement); class MyBehavior : VirtualGridInputBehavior { public MyBehavior(RadVirtualGridElement element) : base(element) { } protected override bool HandleEndKey(KeyEventArgs keys) { this.GridElement.PageIndex = this.GridElement.TotalPages - 1; return true; //return base.HandleEndKey(keys); } }
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: 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 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: 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: - 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: 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.
Hello, we have found another small bug of the RadVirtualGrid control.
When paging is enabled on child view, one of the component of the paging panel overlap whit is parent.
I attach source code and screenshot.
Thanks in advance.
RadVirtualGridElement.Paste does not support pasting into new rows.
I want to override RadVirtualGridElement.Paste to allow to to paste into new rows. Except when I do so, the methods to retrieve information from the clipboard (GetHtmlData/GetTextData/GetCsvData ) are private.
So now I have one request, two solutions:
The problem also occurs, if you just start the form. For example, on 175% (without drag).
This behavior is observed when the VisualStudio2022Light theme is applied. For example, this is not observed in the Fluent theme.
I was trying to move the NewRow to the bottom of the RadVirtualGrid. I learned that this is not possible. During my attempts I ran into a bug:
Reproduction steps:
Expected behavior:
Observed behavior:
I was trying to move the NewRow to the bottom of the RadVirtualGrid. This is also supported by its big brother RadGridView. I have now learned that this is not supported by RadVirtualGrid.
Hereby my request: Please support this!
I've created a Harmony patch (which works for me); it might help you if you decide to support it:
static class MoveNewRowToBottom
{
[HarmonyPatch(typeof(VirtualGridTableElement), "InvalidatePinnedRows")]
static class VirtualGridTableElement_InvalidatePinnedRows
{
static private bool _isInvalidating;
static private bool Prefix(VirtualGridTableElement __instance)
{
if (_isInvalidating)
return false;
_isInvalidating = true;
__instance.ViewElement.TopPinnedRows.DisposeChildren();
__instance.ViewElement.BottomPinnedRows.DisposeChildren();
var viewInfo = __instance.ViewInfo;
var rowsViewState = __instance.RowsViewState;
var topPinnedItems = rowsViewState.TopPinnedItems;
var bottomPinnedItems = rowsViewState.BottomPinnedItems;
if (viewInfo.ShowFilterRow)
if (!topPinnedItems.Contains(RadVirtualGrid.FilterRowIndex) && !bottomPinnedItems.Contains(RadVirtualGrid.FilterRowIndex))
rowsViewState.SetPinPosition(RadVirtualGrid.FilterRowIndex, PinnedRowPosition.Top);
if (viewInfo.ShowNewRow)
if (!topPinnedItems.Contains(RadVirtualGrid.NewRowIndex) && !bottomPinnedItems.Contains(RadVirtualGrid.NewRowIndex))
rowsViewState.SetPinPosition(RadVirtualGrid.NewRowIndex, PinnedRowPosition.Top);
if (viewInfo.ShowHeaderRow)
if (!topPinnedItems.Contains(RadVirtualGrid.HeaderRowIndex) && !bottomPinnedItems.Contains(RadVirtualGrid.HeaderRowIndex))
rowsViewState.SetPinPosition(RadVirtualGrid.HeaderRowIndex, PinnedRowPosition.Top);
var elementProvider = __instance.RowScroller.ElementProvider;
var topPinnedRows = __instance.ViewElement.TopPinnedRows;
foreach (int topPinnedRow in topPinnedItems.SortTopRowIndexes())
{
VirtualGridRowElement pinnedRow = (VirtualGridRowElement)elementProvider.GetElement(topPinnedRow, null);
topPinnedRows.Children.Add(pinnedRow);
pinnedRow.Attach(topPinnedRow, null);
}
var bottomPinnedRows = __instance.ViewElement.BottomPinnedRows;
foreach (int bottomPinnedRow in bottomPinnedItems.SortBottomRowIndexes())
{
VirtualGridRowElement pinnedRow = (VirtualGridRowElement)elementProvider.GetElement(bottomPinnedRow, null);
bottomPinnedRows.Children.Add(pinnedRow);
pinnedRow.Attach(bottomPinnedRow, null);
}
_isInvalidating = false;
return false;
}
}
static private IEnumerable<int> SortTopRowIndexes(this ReadOnlyCollection<int> topRowIndexes)
{
var specialRowIndex = topRowIndexes.Where(index => index < 0).ToList();
if (specialRowIndex.Contains(RadVirtualGrid.HeaderRowIndex))
yield return RadVirtualGrid.HeaderRowIndex;
if (specialRowIndex.Contains(RadVirtualGrid.NewRowIndex))
yield return RadVirtualGrid.NewRowIndex;
if (specialRowIndex.Contains(RadVirtualGrid.FilterRowIndex))
yield return RadVirtualGrid.FilterRowIndex;
foreach (var index in topRowIndexes.Where(index => index >= 0))
yield return index;
}
static private IEnumerable<int> SortBottomRowIndexes(this ReadOnlyCollection<int> bottomRowIndexes)
{
foreach (var index in bottomRowIndexes.Where(index => index >= 0))
yield return index;
var specialRowIndex = bottomRowIndexes.Where(index => index < 0).ToList();
if (specialRowIndex.Contains(RadVirtualGrid.FilterRowIndex))
yield return RadVirtualGrid.FilterRowIndex;
if (specialRowIndex.Contains(RadVirtualGrid.NewRowIndex))
yield return RadVirtualGrid.NewRowIndex;
if (specialRowIndex.Contains(RadVirtualGrid.HeaderRowIndex))
yield return RadVirtualGrid.HeaderRowIndex;
}
}
Repro-steps
Observed behavior
First, lets compare this with when you right click on a record selector (the cell before a row starts, sometimes with an arrow). In that case only that row gets selected, so you visually see what the context menu is about. When you right click on a cell, the selection does not change so the context remains unclear. In my printscreen above it is hard to see on which cell I clicked.
Second, the actions in the context menu target multiple targets or contexts. Copy and Paste target the whole selection. Clear and Edit target the cell, Delete Row targets the row which I clicked on, but which is not visible.
In this case, the user actually wanted to right click and delete ALL rows, which is not part of the context menu. Instead he clicked on Delete Row and he was unaware of what he had actually deleted.
Expected bevahior
Repro steps:
Observed behavior:
Expected behavior:
Observation / suggestion: