How to reproduce: check the attached video as well
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetData();
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Bool", typeof(bool));
for (int i = 0; i < 10; i++)
{
dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i), i % 2 == 0);
}
return dt;
}
private void radButton1_Click(object sender, EventArgs e)
{
this.radGridView1.TableElement.ScrollToRow(0);
this.radGridView1.Focus();
}
}
Workaround: call the method if the row is not selected
private void radButton1_Click(object sender, EventArgs e)
{
if (!this.radGridView1.Rows[0].IsSelected)
{
this.radGridView1.TableElement.ScrollToRow(0);
}
this.radGridView1.Focus();
}
To reproduce:
- Select several rows and cells in excel and copy them.
- Paste in the self-reference grid.
- Only the first row is copied.
Workaround:
private void RadGridView1_Pasting(object sender, GridViewClipboardEventArgs e)
{
e.Cancel = true;
List<List<string>> rows = this.GetTextData();
PrintGridTraverser traverser = new PrintGridTraverser(this.radGridView1.MasterView);
while (traverser.Current != this.radGridView1.CurrentRow)
{
traverser.MoveNext();
}
traverser.MovePrevious();
int rowIndex = 0;
int colIndex = this.radGridView1.CurrentColumn.Index;
while (traverser.MoveNext() && rowIndex < rows.Count)
{
for (int i = colIndex; i < this.radGridView1.Columns.Count && i - colIndex < rows[rowIndex].Count; i++)
{
traverser.Current.Cells[i].Value = rows[rowIndex][i - colIndex];
}
rowIndex++;
}
}
To reproduce:
1. Use the following code:
public Form1()
{
InitializeComponent();
this.radGridView1.EnableFiltering = true;
GridViewDecimalColumn col = new GridViewDecimalColumn();
col.Name = "Calculated Column";
col.HeaderText = "Order value";
radGridView1.Columns.Add(col);
radGridView1.Columns["Calculated Column"].Expression = "Freight/Sum(Freight)";
}
private void Form1_Load(object sender, EventArgs e)
{
this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
this.radGridView1.DataSource = this.ordersBindingSource;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewSummaryItem summaryItem = new GridViewSummaryItem();
summaryItem.Name = "Freight";
summaryItem.Aggregate = GridAggregateFunction.Sum ;
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
summaryRowItem.Add(summaryItem);
this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
this.radGridView1.SummaryRowsBottom.Add(summaryRowItem);
}
2. Filter the grid by EmployeeID for example. You will notice that the summary item for Freight is recalculated considering the filtered rows. However, the calculated column doesn't update its values.
The issue can be reproduced with the .40 version of the assemblies and in a scenario in which the grid is added as a RadMenuHostItem to the Items collection of a drop-down button.
Workaround: set the BindingContext of the grid to equal that of the form:
public Form1()
{
InitializeComponent();
radGridView1.BindingContext = this.BindingContext;
}
Please refer to the attached screenshot.
Workaround:
public Form1()
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add("Id");
dt.Columns.Add("Name");
for (int i = 0; i < 5; i++)
{
dt.Rows.Add(i, "Item" + i);
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.AllowSearchRow = true;
this.radGridView1.SearchRowPosition = Telerik.WinControls.UI.SystemRowPosition.Bottom;
this.radGridView1.ViewDefinition = new CustomTableViewDefition();
}
public class CustomTableViewDefition : TableViewDefinition
{
public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
{
return new CustomTableElement();
}
}
public class CustomTableElement : GridTableElement
{
protected override RowsContainerElement CreateViewElement()
{
return new CustomRowsContainerElement();
}
}
public class CustomRowsContainerElement : RowsContainerElement
{
protected override SizeF ArrangeOverride(SizeF finalSize)
{
float y = 0;
this.TopPinnedRows.Arrange(new RectangleF(0, y, finalSize.Width, this.TopPinnedRows.DesiredSize.Height));
y += this.TopPinnedRows.DesiredSize.Height + ElementSpacing;
this.ScrollableRows.Arrange(new RectangleF(0, y, finalSize.Width, this.ScrollableRows.DesiredSize.Height));
y += this.ScrollableRows.DesiredSize.Height + ElementSpacing;
this.BottomPinnedRows.Arrange(new RectangleF(0, finalSize.Height - this.BottomPinnedRows.DesiredSize.Height,
finalSize.Width, this.BottomPinnedRows.DesiredSize.Height));
return finalSize;
}
}
To reproduce:
Sub New()
InitializeComponent()
Dim dt As New DataTable
dt.Columns.Add("Id", GetType(Integer))
dt.Columns.Add("Name", GetType(String))
For index = 1 To 200000
dt.Rows.Add(index, "Item" & index)
Next
Me.RadGridView1.DataSource = dt
Me.RadGridView1.MultiSelect = True
Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Dim sw As New Stopwatch
sw.Start()
Dim mi As MethodInfo = GetType(GridViewSelectedCellsCollection).GetMethod("BeginUpdate", BindingFlags.Instance Or BindingFlags.NonPublic)
mi.Invoke(Me.RadGridView1.MasterTemplate.SelectedCells, Nothing)
For Each row As GridViewDataRowInfo In Me.RadGridView1.Rows
row.Cells("Name").IsSelected = True
Next
Dim mi2 As MethodInfo = GetType(GridViewSelectedCellsCollection).GetMethod("EndUpdate", BindingFlags.Instance Or BindingFlags.NonPublic)
mi2.Invoke(Me.RadGridView1.MasterTemplate.SelectedCells, New Object() {True})
sw.Stop()
RadMessageBox.Show(sw.ElapsedMilliseconds)
End Sub
To reproduce:
public RadForm1()
{
InitializeComponent();
this.radGridView1.MasterTemplate.Columns.Add(new GridViewDecimalColumn("ParentId"));
this.radGridView1.MasterTemplate.Columns.Add(new GridViewTextBoxColumn("ParentName"));
this.radGridView1.MasterTemplate.Rows.Add(1, "Item" + 1);
this.radGridView1.MasterTemplate.Rows.Add(2, "Item" + 2);
this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
for (int i = 0; i < 10; i++)
{
GridViewTemplate template = new GridViewTemplate();
template.AllowAddNewRow = false;
template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
template.Caption = "Tab" + i;
template.Columns.Add(new GridViewDecimalColumn("Id"));
template.Columns.Add(new GridViewTextBoxColumn("Name"));
this.radGridView1.MasterTemplate.Templates.Add(template);
template.HierarchyDataProvider = new GridViewEventDataProvider(template);
}
this.radGridView1.RowSourceNeeded += radGridView1_RowSourceNeeded;
}
private void radGridView1_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
{
for (int i = 0; i < 10; i++)
{
GridViewRowInfo row = e.Template.Rows.NewRow();
row.Cells["Id"].Value = e.ParentRow.Cells["ParentId"].Value;
row.Cells["name"].Value = "child row" + i;
e.SourceCollection.Add(row);
}
}
private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
GridDetailViewCellElement cell = e.CellElement as GridDetailViewCellElement;
if (cell != null)
{
RadPageViewStripElement strip = cell.PageViewElement as RadPageViewStripElement;
strip.StripButtons = StripViewButtons.LeftScroll | StripViewButtons.RightScroll;
}
}
If you have just one row on the master level, the strip buttons don't navigate the tabs.
Workaround: add a dummy row that is hidden:
private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
{
if (e.RowElement.RowInfo == this.radGridView1.Rows.Last())
{
e.RowElement.RowInfo.Height = 1;
e.RowElement.RowInfo.MinHeight = 1;
e.RowElement.RowInfo.MaxHeight = 1;
}
else
{
e.RowElement.RowInfo.Height = 25;
e.RowElement.RowInfo.MinHeight = 25;
e.RowElement.RowInfo.MaxHeight = 25;
}
}
Use the attached project to reproduce. The video shows what steps you need to take.
Use attached project to reproduce. The video shows what steps you need to take. Workaround: Use CellEndEdit instead.
Please refer to the attached sample project which result is illustrated in the provided screenshot. Workaround: this.radGridView1.ClearSelection(); this.radGridView1.CurrentRow = null; this.radGridView1.Rows[1].Cells[2].IsSelected = true;
Workaround: custom CompositeFilterForm
private void radGridView1_CreateCompositeFilterDialog(object sender, GridViewCreateCompositeFilterDialogEventArgs e)
{
e.Dialog = new MyCompositeFilterForm();
}
public class MyCompositeFilterForm : CompositeFilterForm
{
public override void Initialize(GridViewDataColumn dataColumn, Telerik.WinControls.Data.FilterDescriptor filterDescriptor, bool useTypedEditors)
{
base.Initialize(dataColumn, filterDescriptor, useTypedEditors);
if (dataColumn.Name == "Time")
{
RadDateTimePicker rEditor = (RadDateTimePicker)this.RightEditor;
rEditor.DateTimePickerElement.ShowTimePicker = true;
rEditor.DateTimePickerElement.CalendarSize = new Size(500, 250);
RadDateTimePicker lEditor = (RadDateTimePicker)this.LeftEditor;
lEditor.DateTimePickerElement.ShowTimePicker = true;
lEditor.DateTimePickerElement.CalendarSize = new Size(500, 250);
}
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
base.OnClosing(e);
if (this.DialogResult == DialogResult.OK)
{
object leftValue = this.GetValueFromDateEditor(this.LeftEditor);
if (leftValue != null)
{
this.LeftDescriptor.Value = leftValue;
}
object rightValue = this.GetValueFromDateEditor(this.RightEditor);
if (rightValue != null)
{
this.RightDescriptor.Value = rightValue;
}
}
}
protected virtual object GetValueFromDateEditor(RadControl editorControl)
{
object value = null;
if (editorControl is RadDateTimePicker)
{
value = ((RadDateTimePicker)editorControl).Value;
return value;
}
return value;
}
}
To reproduce: The attached video shows how you can reproduce this. Workaround: Use the Properties window to remove summary rows.
To reproduce: please refer o the attached sample project: 1.Click the left button. A new row will be added to the left grid and the grid will scroll to it. 2. Move the scrollbar back to the top and sort the ID column. 3. Click the left button again. A new row will be added but the grid won't scroll to it. Perform the same steps with the right grid. The grid scrolls as expected when you add a new row in a sorted grid. Workaround: use the Rows.Add method instead of Rows.AddNew.
To reproduce: please refer to the attached gif file and sample project. The multiple newly added rows are selected only when the grid is not sorted.
Workaround: use Begin/EndUpdate when adding multiple rows
private void radButton1_Click(object sender, EventArgs e)
{
this.radGridView1.ClearSelection();
this.radGridView1.BeginUpdate();
for (int i = 0; i < 3; i++)
{
GridViewDataRowInfo row = new GridViewDataRowInfo(this.radGridView1.MasterView);
row.IsSelected = true;
row.IsCurrent = true;
row.Cells["Id"].Value = this.radGridView1.Rows.Count;
row.Cells["Name"].Value = "Row" + row.Cells["Id"].Value;
this.radGridView1.Rows.Add(row);
}
this.radGridView1.EndUpdate();
}
Please refer to the attached gif file illustrating how to reproduce the error with the Demo application. Workaround: this.radGridView1.UseScrollbarsInHierarchy = true;
To reproduce: populate the grid with data and use the following code snippet:
Me.RadGridView1.EnableAlternatingRowColor = True
Me.RadGridView1.TableElement.AlternatingRowColor = Color.LightGray
Me.RadGridView1.MultiSelect = True
Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect
Select multiple cells from different rows. You will notice that alternating color is not applied to the rows for which you have a selected cell. The attached gif file illustrates the behavior.
Workaround:
Sub New()
InitializeComponent()
Me.RadGridView1.MultiSelect = True
Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect
End Sub
Private Sub RadGridView1_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) _
Handles RadGridView1.CellFormatting
e.CellElement.DrawFill = True
e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid
If e.CellElement.IsSelected Then
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local)
ElseIf e.CellElement.RowInfo.Index Mod 2 = 0 Then
e.CellElement.BackColor = Color.White
Else
e.CellElement.BackColor = Color.LightGray
End If
End Sub
To reproduce: populate a grid and enable multiple selection. Use cell selection. When you click the row header, the entire row (all cells from the row) is selected no matter the SelectionMode. However, if you start a selection from the row header and move the cursor, only the cells from the first column get selected. The attached gif file illustrates the behavior. The expected behavior is that all cells from the affected columns should be selected when starting the selection from the row header.
Workaround:
Sub New()
InitializeComponent()
Me.RadGridView1.MultiSelect = True
Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect
AddHandler Me.RadGridView1.MouseDown, AddressOf GridMouseDown
AddHandler Me.RadGridView1.MouseUp, AddressOf GridMouseUp
AddHandler Me.RadGridView1.MouseMove, AddressOf GridMouseMove
End Sub
Dim isMouseDown = False
Dim startRow As GridViewRowInfo
Dim lastHoveredCell As GridCellElement
Private Sub GridMouseDown(sender As Object, e As MouseEventArgs)
Dim cell As GridRowHeaderCellElement = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridRowHeaderCellElement)
If cell IsNot Nothing Then
isMouseDown = True
startRow = cell.RowInfo
End If
End Sub
Private Sub GridMouseUp(sender As Object, e As MouseEventArgs)
isMouseDown = False
startRow = Nothing
End Sub
Private Sub GridMouseMove(sender As Object, e As MouseEventArgs)
If isMouseDown Then
Dim cellUnderMouse As GridCellElement = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridCellElement)
If cellUnderMouse IsNot Nothing AndAlso Not cellUnderMouse.Equals(lastHoveredCell) Then
lastHoveredCell = cellUnderMouse
Me.RadGridView1.ClearSelection()
Me.RadGridView1.SelectedCells.BeginUpdate()
If startRow.Index > cellUnderMouse.RowInfo.Index Then
For index = cellUnderMouse.RowInfo.Index To startRow.Index
Me.RadGridView1.Rows(index).IsSelected = True
Next
Else
For index = startRow.Index To cellUnderMouse.RowInfo.Index
For Each cell As GridViewCellInfo In Me.RadGridView1.Rows(index).Cells
cell.IsSelected = True
Next
Next
End If
Me.RadGridView1.SelectedCells.EndUpdate(True)
End If
End If
End Sub
To reproduce: - Add one-to-many relations hierarchy 3 or more child templates. - Export the grid using GridViewSpreadExport - The child rows of the last parent row are missing. Workaround: Add an empty parent row at the end of the grid.