How to reproduce check the attached project: Workaround: Create a custom spread export renderer public class MySpreadExportRenderer : SpreadExportRenderer { public override void AddWorksheet(string sheetName) { string name = ""; Workbook wb = (Workbook)typeof(SpreadExportRenderer).GetField("workbook", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this); if (sheetName == null || sheetName == string.Empty) { name = "Sheet_" + (wb.Worksheets.Count + 1); } else { name = sheetName; } if (wb.Worksheets.Where(w => w.Name == name).ToList().Count == 0) { base.AddWorksheet(sheetName); } else { typeof(SpreadExportRenderer).GetField("worksheet", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, wb.Worksheets.Add()); } } }
To reproduce: please refer to the attached gif file. Workaround: public RadForm1() { InitializeComponent(); this.radGridView1.CellClick+=radGridView1_CellClick; } private void radGridView1_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { if (e.Column is Telerik.WinControls.UI.GridViewRowHeaderColumn) { this.radGridView1.CloseEditor(); } }
Workaround: Friend Class MyRadGridView Inherits RadGridView Public Overrides Property ThemeClassName As String Get Return GetType(RadGridView).FullName End Get Set(value As String) MyBase.ThemeClassName = value End Set End Property Protected Overrides Function CreateGridViewElement() As RadGridViewElement Return New MyRadGridViewElement() End Function End Class Friend Class MyRadGridViewElement Inherits RadGridViewElement Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(RadGridViewElement) End Get End Property Protected Overrides Function CreateGroupPanelElement() As GroupPanelElement Return New MyGroupPanelElement() End Function End Class Friend Class MyGroupPanelElement Inherits GroupPanelElement Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(GroupPanelElement) End Get End Property Protected Overrides Function ArrangeOverride(finalSize As SizeF) As SizeF Dim clientRect As RectangleF = Me.GetClientRectangle(finalSize) Dim sizeGripRect As New RectangleF(clientRect.X, clientRect.Bottom - Me.SizeGrip.DesiredSize.Height, clientRect.Width, Me.SizeGrip.DesiredSize.Height) Me.SizeGrip.Arrange(sizeGripRect) clientRect.Height -= Me.SizeGrip.DesiredSize.Height Dim groupHeaderRect As New RectangleF(clientRect.X, clientRect.Y, Me.Header.DesiredSize.Width, clientRect.Height) Me.Header.Arrange(groupHeaderRect) clientRect.Width -= Me.Header.DesiredSize.Width Dim scrollViewRect As New RectangleF(clientRect.X + Me.Header.DesiredSize.Width, clientRect.Y, clientRect.Width, clientRect.Height) If scrollViewRect.Width > 20 Then Me.ScrollView.Arrange(scrollViewRect) End If Return finalSize End Function End Class
How to reproduce: check the attached video Workaround: disable pinning of the last row when it is in a group public partial class Form1 : Form { DataTable dt; public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.ContextMenuOpening += RadGridView1_ContextMenuOpening; } private void RadGridView1_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e) { GridRowHeaderCellElement header = e.ContextMenuProvider as GridRowHeaderCellElement; if (header != null && header.RowInfo.Group != null) { var notPinned = header.RowInfo.Group.GroupRow.ChildRows.Where(r => r.IsPinned == false).ToList(); if (notPinned.Count <= 1) { e.ContextMenu.Items.RemoveAt(0); e.ContextMenu.Items.RemoveAt(0); } } } private DataTable GetData() { 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 < 2; i++) { for (int j = 0; j < 2; j++) { dt.Rows.Add(i, "Name " + i + " " + j, DateTime.Now.AddDays(i), i % 2 == 0); } } return dt; } }
How to reproduce: public partial class Form1 : Form { DataTable dt; public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } private void radButton1_Click(object sender, EventArgs e) { dt.Clear(); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "New Name " + i, DateTime.Now.AddDays(i), i % 2 == 0); } } private DataTable GetData() { 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 < 500; i++) { dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i), i % 2 == 0); } return dt; } } Workaround: public partial class Form1 : Form { DataTable dt; public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.RowsChanged += RadGridView1_RowsChanged; } private void RadGridView1_RowsChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Reset) { this.radGridView1.MasterView.PinnedRows.GetType().GetMethod("Clear", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) .Invoke(this.radGridView1.MasterView.PinnedRows, new object[] { }); } } private void radButton1_Click(object sender, EventArgs e) { dt.Clear(); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "New Name " + i, DateTime.Now.AddDays(i), i % 2 == 0); } } private DataTable GetData() { 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 < 500; i++) { dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i), i % 2 == 0); } return dt; } }
Workaround: AddHandler Me.RadGridView1.CreateCompositeFilterDialog, AddressOf CreateCompositeFilterDialog Private Sub CreateCompositeFilterDialog(sender As Object, e As GridViewCreateCompositeFilterDialogEventArgs) Dim dialog As New CompositeDataFilterForm() AddHandler dialog.DataFilter.EditorRequired, AddressOf EditorRequired e.Dialog = dialog End Sub Private Sub EditorRequired(sender As Object, e As TreeNodeEditorRequiredEventArgs) Dim filterNode As DataFilterCriteriaNode = TryCast(e.Node, DataFilterCriteriaNode) If filterNode IsNot Nothing AndAlso filterNode.PropertyName = "BASE_NULL_DATE" AndAlso TypeOf sender Is DataFilterValueEditorElement Then e.Editor = New TreeViewDateTimeEditor() End If End Sub
To reproduce: private void RadGridView1_KeyPress(object sender, KeyPressEventArgs e) { int startIndex = radGridView1.CurrentRow.Index +1; for (int i = startIndex; i < radGridView1.Rows.Count; i++) { var value = radGridView1.Rows[i].Cells["Name"].Value.ToString().ToLower(); if (value.StartsWith(e.KeyChar.ToString())) { radGridView1.TableElement.ScrollToRow(radGridView1.Rows[i]); radGridView1.ClearSelection(); radGridView1.Rows[i].IsSelected = true; radGridView1.Rows[i].IsCurrent = true; radGridView1.Columns[1].IsCurrent = true; break; } } } - Press some key so the grid is scrolled down, then press the down key. - The first row is selected instead of the next one. Workaround: remove this line: radGridView1.Rows[i].IsSelected = true;
To reproduce: 1. Run the attached sample project. 2. Right-click the grid. 3. Quickly navigate to another application (e.g. Windows Explorer) before the context menu is shown & wait at windows explorer to display the menu 4. The context will be stuck.
To reproduce: this.radGridView1.MultiSelect = true; this.radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect; radGridView1.ShowRowHeaderColumn = false; Then select the cells in the firs column by dragging the mouse. Workaround: // radGridView1.ShowRowHeaderColumn = false; radGridView1.TableElement.RowHeaderColumnWidth = 0;
How to reproduce: public partial class Form1 : Form { private RadGridView grid = new RadGridView(); public Form1() { InitializeComponent(); Controls.Add(grid); grid.Dock = DockStyle.Fill; grid.DataSource = this.GetData(); } private object GetData() { DataTable dataTable = new DataTable(); dataTable.Columns.Add("Id", typeof(int)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Checked", typeof(bool)); for (int i = 0; i < 200; i++) { dataTable.Rows.Add(i, "Name " + i, i % 2 == 0); } return dataTable; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewCheckBoxColumn checkBoxColumn = (GridViewCheckBoxColumn)grid.Columns["Checked"]; checkBoxColumn.EnableHeaderCheckBox = true; checkBoxColumn.SortOrder = RadSortOrder.Ascending; } } Workaround: public partial class Form1 : Form { private RadGridView grid = new RadGridView(); public Form1() { InitializeComponent(); Controls.Add(grid); grid.Dock = DockStyle.Fill; grid.DataSource = this.GetData(); grid.MouseDown += grid_MouseDown; grid.MouseUp += grid_MouseUp; } private object GetData() { DataTable dataTable = new DataTable(); dataTable.Columns.Add("Id", typeof(int)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Checked", typeof(bool)); for (int i = 0; i < 200; i++) { dataTable.Rows.Add(i, "Name " + i, i % 2 == 0); } return dataTable; } private void grid_MouseDown(object sender, MouseEventArgs e) { RadGridView grid = (RadGridView)sender; RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement; if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement) { sw = new Stopwatch(); sw.Start(); grid.BeginUpdate(); } } Stopwatch sw; private void grid_MouseUp(object sender, MouseEventArgs e) { RadGridView grid = (RadGridView)sender; RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement; if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement) { grid.EndUpdate(); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewCheckBoxColumn checkBoxColumn = (GridViewCheckBoxColumn)grid.Columns["Checked"]; checkBoxColumn.EnableHeaderCheckBox = true; checkBoxColumn.SortOrder = RadSortOrder.Ascending; } }
To reproduce: please refer to the attached sample project and follow the steps in the provided gif file: 1. Enter something in the search bar 2. Filter on some column, uncheck "All", then select a few items, then validate 3. Click on a random row on the grid 4. Filter on the same column as in 2., check "All", then uncheck a few items, then validate Workaround: private void radGridView1_FilterChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e) { this.radGridView1.MasterTemplate.Refresh(); }
Please refer to the attached sample project and gif file illustrating the behavior. ColumnGroupsViewDefinition view = this.radGridView1.ViewDefinition as ColumnGroupsViewDefinition; foreach (GridViewColumnGroup group in view.ColumnGroups) { group.ShowHeader = false; } Workaround: use the ViewCellFormatting and enable the back color for the header cells that are over the hidden group headers public RadForm1() { InitializeComponent(); ColumnGroupsViewDefinition view = this.radGridView1.ViewDefinition as ColumnGroupsViewDefinition ; foreach (GridViewColumnGroup group in view.ColumnGroups) { group.ShowHeader = false; } } private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { if (e.Row is GridViewTableHeaderRowInfo && !(e.CellElement is GridColumnGroupCellElement)) { e.CellElement.DrawFill = true; e.CellElement.BackColor = Color.FromArgb(234, 242, 252); e.CellElement.GradientStyle = GradientStyles.Solid; } else { e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local); } }
How to reproduce: public partial class Form1 : Form { public class Data { public bool Checked { get; set; } public string Text { get; set; } } private readonly RadGridView _grid; private readonly List<Data> _dataList = new List<Data> { new Data {Text = "abc"}, new Data {Text = "def"}, new Data {Text = "ghi"}, new Data {Text = "jkl"}, new Data {Text = "mno"}, new Data {Text = "pqr"}, new Data {Text = "stu"}, new Data {Text = "vwx"}, new Data {Text = "yz0"} }; public Form1() { InitializeComponent(); _grid = new RadGridView { Dock = DockStyle.Fill, AllowSearchRow = true }; Controls.Add(_grid); _grid.DataSource = _dataList; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); _grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; ((GridViewCheckBoxColumn)_grid.Columns["Checked"]).EnableHeaderCheckBox = true; _grid.Columns["Checked"].SortOrder = RadSortOrder.Ascending; ((GridViewCheckBoxColumn)_grid.Columns["Checked"]).Checked = ToggleState.On; _grid.MasterView.TableSearchRow.Search("abc"); } } Workaround: clear the search text protected override void OnLoad(EventArgs e) { base.OnLoad(e); _grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; ((GridViewCheckBoxColumn)_grid.Columns["Checked"]).EnableHeaderCheckBox = true; _grid.Columns["Checked"].SortOrder = RadSortOrder.Ascending; ((GridViewCheckBoxColumn)_grid.Columns["Checked"]).Checked = ToggleState.On; _grid.MasterView.TableSearchRow.Search("abc"); this._grid.MouseDown += _grid_MouseDown; } private void _grid_MouseDown(object sender, MouseEventArgs e) { RadGridView grid = (RadGridView)sender; RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement; if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement && grid.SortDescriptors.Count > 0)) { grid.MasterView.TableSearchRow.Search(""); } }
To reproduce: protected override void OnLoad(EventArgs e) { base.OnLoad(e); DataTable dt = NewDt(); this.radGridView1.DataSource = dt; var c = this.radGridView1.Columns["Calculted"] as GridViewDecimalColumn; c.EnableExpressionEditor = true; c.Expression = "Column2 / SUM(Column2) * 10"; c.DecimalPlaces = 2; c.FormatString = "{0:N2}"; this.radGridView1.GroupDescriptors.Add("GroupByColumn", ListSortDirection.Ascending); } private DataTable NewDt() { var dt = new DataTable(); dt.Columns.Add("ItemColumn"); dt.Columns.Add("GroupByColumn"); dt.Columns.Add("Column2", typeof(decimal)); dt.Columns.Add("Calculted", typeof(decimal)); for (int i = 1; i <= 20; i++) { string gr = string.Empty; if (i % 3 == 0) gr = "gr3"; else if (i % 2 == 0) gr = "gr2"; else if (i % 5 == 0) gr = "gr5"; else gr = "item" + i.ToString(); dt.Rows.Add("id #" + i.ToString(), gr, i, 0); } return dt; } Workaround: public class CustomExpressionContext : Telerik.Data.Expressions.ExpressionContext { RadGridView radGridView; public CustomExpressionContext(RadGridView grid) { this.radGridView = grid; } public decimal MySum(string columnName) { decimal sum = 0; foreach (var item in radGridView.Rows) { sum += (decimal)item.Cells[columnName].Value; } return sum; } } Telerik.Data.Expressions.ExpressionContext.Context = new CustomExpressionContext(this.radGridView1);
To reproduce: please refer to the attached sample project and gif file illustrating the behavior. Add cell value in the new row and press teh down arrow. Workaround: this.radGridView1.MasterTemplate.SelectLastAddedRow = false; This problem is applicable for OpenEdge as well: http://knowledgebase.progress.com/articles/Article/Telerik-RadGridView-highlights-unnecessary-columns-and-rows-in-batch-mode
To reproduce: private void MasterTemplate_ViewChanged(object sender, DataViewChangedEventArgs args) { if (args.Action == ViewChangedAction.ExpandedChanged) { } } Workaround: - Use the GroupExpanded event.
To reproduce: - Add default values for all cells in the grid. - Try to add the new row without changing any value. Workaround: private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { var editor = radGridView1.ActiveEditor as BaseInputEditor; var field = editor.GetType().GetField("originalValue", BindingFlags.NonPublic | BindingFlags.Instance); field.SetValue(editor, "asd"); }
To reproduce: - Add DateTime columns to the grid and set the MaskType of the editor to FreeFormDateTime. - Go to the new row enter a valid date and press Tab. Workaround: class Myditor : RadDateTimeEditor { public override bool IsModified { get { return true; } } }
Please refer to the attached sample project and gif file illustrating the problem. Workaround: Sub New() InitializeComponent() AddHandler Me.RadGridView1.CreateCell, AddressOf RadGridView_CreateCell End Sub Public Class CustomGridFilterCellElement Inherits GridFilterCellElement Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(GridFilterCellElement) End Get End Property Public Sub New(column As GridViewDataColumn, row As GridRowElement) MyBase.New(column, row) End Sub Protected Overrides Function ApplyFormatString(value As Object) As String Return CDate(value).ToString("dd.MM.yyyy") End Function End Class
To reproduce: this.Controls.Add(this.radGridView1); this.radScheduler1.Dock = DockStyle.Fill; List<GridRec> records = new List<GridRec>(); GridRec rec = new GridRec(); rec.Column1 = "1"; rec.Column2 = "2"; rec.Column3 = "3"; rec.Column4 = "4"; rec.Column5 = "5"; rec.Column6 = "6"; rec.Column7 = "7"; rec.Column8 = "8"; rec.Column9 = "9"; for (int i = 0; i < 20; ++i) { records.Add(rec.Clone()); } radGridView1.DataSource = records; this.radGridView1.MultiSelect = true; this.radGridView1.SelectionMode = GridViewSelectionMode.CellSelect; this.radGridView1.Dock = DockStyle.Fill; public class GridRec { public GridRec Clone() { return this.MemberwiseClone() as GridRec; } public string Column1 { get; set; } public string Column2 { get; set; } public string Column3 { get; set; } public string Column4 { get; set; } public string Column5 { get; set; } public string Column6 { get; set; } public string Column7 { get; set; } public string Column8 { get; set; } public string Column9 { get; set; } } If you run the application, it starts with the upper-left most cell selected. Now, while holding down the Shift key, left-click on the cell in the 5th column of the 5th row (cell 5:5). Note all 25 cells are selected as expected. Now, while still holding Shift, left-click again on cell 5:5 and note the selection is cleared. Now, while still holding Shift, click on cell 4:4 (4th column, 4th row). Note how the selected range is now cells 1:1 through 4:4. And while still holding Shift, if you click on 4:4 yet again, the selection is cleared. Workaround: private void radGridView1_SelectionChanging(object sender, Telerik.WinControls.UI.GridViewSelectionCancelEventArgs e) { if (e.ColumnStartIndex == e.ColumnEndIndex && Control.ModifierKeys == Keys.Shift) { e.Cancel = true; } }