To reproduce: add a RadGridView and bind it to Employees data table. Use the following code snippet: Me.RadGridView1.EnableGrouping = True Me.RadGridView1.EnableFiltering = True Dim summaryItem As New GridViewSummaryItem() summaryItem.Name = "Address" summaryItem.Aggregate = GridAggregateFunction.Count Dim summaryRowItem As New GridViewSummaryRowItem() summaryRowItem.Add(summaryItem) Me.RadGridView1.SummaryRowsTop.Add(summaryRowItem) Me.RadGridView1.MasterTemplate.ShowParentGroupSummaries = True 1. Group by "Title" and expand "Sales Representative" group. 2. Group by "Country" and "City". 3.Expand "Sales Representative" group >> "UK" sub-group >> "London" sub-group. You will notice that the summary row shows "3", because you actually have 3 employees in "London" group. 4.Filter by "FirstName" (Contains: "a" for example). As a result 2 employess will remain in "London" group, but the summary row will continue displaying "3". The attached gif file illustrates better the described behavior. Workaround: in the FilterChanged event store the applied GroupDescriptors, clear the RadGridView.GroupDescriptors collection, and add again the stored descriptors. Note that it is necessary to store the expanded groups and restore their state as well.
To reproduce: use the following code snippet and refer to the attached sample gif file. When you enter edit mode for the first time, the editor is empty. Each next entering edit mode displays the respective text in the editor, although it is cut off. public Form1() { InitializeComponent(); radGridView1.Font = new Font("Segoe UI", 18.0f); radGridView1.CellEditorInitialized += pgGrid_CellEditorInitialized; AddColumns(); radGridView1.DataSource = BuildDummyTable(); radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; } private void pgGrid_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadTextBoxEditor editor = e.ActiveEditor as RadTextBoxEditor; if (editor != null) { ((RadTextBoxEditorElement)editor.EditorElement).TextBoxItem.Multiline = true; ((RadTextBoxEditorElement)editor.EditorElement).Padding = new Padding(0); } } private void AddColumns() { GridViewTextBoxColumn colA = new GridViewTextBoxColumn("colA"); radGridView1.Columns.Add(colA); GridViewTextBoxColumn colB = new GridViewTextBoxColumn("colB"); radGridView1.Columns.Add(colB); GridViewTextBoxColumn colC = new GridViewTextBoxColumn("colC"); radGridView1.Columns.Add(colC); GridViewTextBoxColumn colD = new GridViewTextBoxColumn("colD"); radGridView1.Columns.Add(colD); } private DataTable BuildDummyTable() { DataTable table = new DataTable(); table.Columns.Add("colA"); table.Columns.Add("colB"); table.Columns.Add("colC"); table.Columns.Add("colD"); table.Rows.Add("value 1A", "value 1B", "value 1C", "value 1D"); table.Rows.Add("value 2A", "value 2B", "value 2C", "value 2D"); table.Rows.Add("value 3A", "value 3B", "value 3C", "value 3D"); return table; }
Use the following code snippet: public Form1() { InitializeComponent(); GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("Id"); radGridView1.MasterTemplate.Columns.Add(decimalColumn); GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn("Name"); radGridView1.MasterTemplate.Columns.Add(textBoxColumn); GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn("CreatedOn"); radGridView1.MasterTemplate.Columns.Add(dateTimeColumn); radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < 10; i++) { radGridView1.Rows.Add(i, "Name" + i, DateTime.Now.AddDays(i)); } radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.Disable; } If you copy a cell content and try to paste it to another cell of the same column, the content is pasted successfully, although the ClipboardPasteMode property is set to Disable.
To reproduce: DataTable t = new DataTable(); t.Columns.Add("timeSpan", typeof(TimeSpan)); t.Rows.Add(TimeSpan.FromHours(11)); t.Rows.Add(TimeSpan.FromHours(2)); t.Rows.Add(TimeSpan.FromHours(4)); t.Rows.Add(TimeSpan.FromMinutes(17)); radGridView1.DataSource = t; GridViewSummaryItem summaryItem = new GridViewSummaryItem(); summaryItem.Name = "timeSpan"; summaryItem.Aggregate = GridAggregateFunction.Sum; GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(); summaryRowItem.Add(summaryItem); this.radGridView1.SummaryRowsTop.Add(summaryRowItem); Workaround: CustomSummaryItem summaryItem = new CustomSummaryItem("timeSpan", "", GridAggregateFunction.Sum); GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(); summaryRowItem.Add(summaryItem); this.radGridView1.SummaryRowsTop.Add(summaryRowItem); public class CustomSummaryItem : GridViewSummaryItem { public CustomSummaryItem(string name, string formatString, GridAggregateFunction aggregate) : base(name, formatString, aggregate) { } public override object Evaluate(IHierarchicalRow row) { TimeSpan timeSpanSum = new TimeSpan(); foreach (GridViewRowInfo childRow in row.ChildRows) { timeSpanSum += (TimeSpan)childRow.Cells["timeSpan"].Value; } return timeSpanSum; } }
To reproduce: - Add two GridViewMultiComboBoxColumns with different number of columns to a grid. - set AutoSizeDropDownToBestFit to true in the CellEditorInitialized event. - Start the project and open the drop down for the first column and then for the second. - You will notice that the second time the drop down size is not calculated properly. Workaround: void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadMultiColumnComboBoxElement el = e.ActiveEditor as RadMultiColumnComboBoxElement; if (el != null) { FieldInfo propertyInfo = el.GetType().GetField("savedColumnsWidth", BindingFlags.NonPublic | BindingFlags.Instance); propertyInfo.SetValue(el, -1); el.AutoSizeDropDownToBestFit = true; } }
To reproduce: - Add a grid to a blank form. - Group the grid on a single column and expand a group row. - Add and then remove a summary row by calling the clear method. - You will notice that the summary row is not removed. Workaround: reset the groups after the summary rows are cleared: radGridView1.SummaryRowsBottom.Clear(); List<GroupDescriptor> list = new List<GroupDescriptor>(); foreach (var item in radGridView1.GroupDescriptors) { list.Add(item); } radGridView1.GroupDescriptors.Clear(); radGridView1.MasterTemplate.Refresh(); foreach (var item in list) { radGridView1.GroupDescriptors.Add(item); } radGridView1.MasterTemplate.Refresh();
To reproduce: Download the attached files. One contains a project with TelerikDataAccess, the other one contains the SQL script to create the database. Before starting the project notice the column with header text "column1". You will see that its expression is as follows: "Player.Person.FirstName+\",\"+Player.Person.LastName". Starting the project at this point will not produce an exception. Change the name of the column to FirstName and start the project, you will see the stack overflow exception.
To reproduce: Add a row to RadGridView and select it. Then remove it from the rows. Check the SelectedRows collection and you will see that the row is inside. The collection should not contain removed rows and the SelectionChanged event should be fired when a selected row is removed. Workaround: Set the IsSelected property of the row to false prior removing it.
To reproduce: Open the examples and navigate to GridView -> RightToLeft and toggle on RightToLeft. You will see that the GridGroupHeaderRowElements will have its text LeftToRight. Workaround: Use ViewCellFormatting: private void Grid_ViewCellFormatting15(object sender, CellFormattingEventArgs e) { if (e.CellElement.RowElement is GridGroupHeaderRowElement && e.CellElement.RowElement.Children.Any() && e.CellElement.RowElement.Children.Last() is GridGroupContentCellElement) { (e.CellElement.RowElement.Children.Last() as GridGroupContentCellElement).TextAlignment = System.Drawing.ContentAlignment.MiddleRight; } }
To reproduce: - Set EnterKeyMode to EnterMovesToNextRow. - Enter an invalid value in the first cell and press enter two times. - Enter valid value and press enter again. - You will notice that the current row is moved appropriately.
To reproduce: Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products) Dim menu As New ContextMenu() For index = 1 To 4 menu.MenuItems.Add("item" & index) Next Me.ContextMenu = menu End Sub Workaround: Const WM_CONTEXTMENU As Integer = &H7B Public Class Grid Inherits RadGridView Protected Overrides Sub WndProc(ByRef m As Message) If m.Msg = WM_CONTEXTMENU Then Return End If MyBase.WndProc(m) End Sub Public Overrides Property ThemeClassName As String Get Return GetType(RadGridView).FullName End Get Set(value As String) MyBase.ThemeClassName = value End Set End Property End Class
To reproduce: -Add GridViewMaskBoxColumn to a grid. -Set the Mask type to Regex and set any mask you want. -When you leave the cell NullRefernceException is thrown.
To reproduce: 1. Add a RadGridView and bind it to Northwind.Products table. 2. Use the following code: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products) For Each col As GridViewColumn In Me.RadGridView1.Columns If Not col.HeaderText = "SupplierID" AndAlso Not col.HeaderText = "ProductID" Then col.ReadOnly = True End If Next Me.RadGridView1.AddNewRowPosition = SystemRowPosition.Bottom End Sub Private Sub RadGridView1_CellValidating(sender As Object, e As CellValidatingEventArgs) Handles RadGridView1.CellValidating If e.Value Is Nothing Then If MessageBox.Show("Incorrect", "error", MessageBoxButtons.OKCancel) = Windows.Forms.DialogResult.OK Then e.Cancel = True End If End If End Sub 3. Run the project and go to the new row ,cell "SupplierID". 4. Clear the value and press Tab key. As a result the message box for error indication is shown twice. Workaround: 'register the custom row behavior Dim gridBehavior As BaseGridBehavior = TryCast(RadGridView1.GridBehavior, BaseGridBehavior) gridBehavior.UnregisterBehavior(GetType(GridViewNewRowInfo)) gridBehavior.RegisterBehavior(GetType(GridViewNewRowInfo), New MyNewRowBehavior()) Me.RadGridView1.GridViewElement.Navigator = New MyGridNavigator() Public Class MyNewRowBehavior Inherits GridNewRowBehavior Protected Overrides Function ProcessTabKey(keys As KeyEventArgs) As Boolean If Me.GridControl.AddNewRowPosition = SystemRowPosition.Bottom AndAlso _ Me.GridControl.IsInEditMode AndAlso Me.GridViewElement.Navigator.IsLastColumn(GridViewElement.CurrentColumn) Then Me.GridControl.Tag = "SuspendValidation" End If Return MyBase.ProcessTabKey(keys) End Function End Class Public Class MyGridNavigator Inherits BaseGridNavigator Public Overrides Function SelectFirstColumn() As Boolean If Me.GridViewElement.GridControl.Tag = "SuspendValidation" Then Me.GridViewElement.GridControl.Tag = Nothing Return False End If Return MyBase.SelectFirstColumn() End Function End Class
To reproduce: 1. Add a RadGridView and a RadButton. 2. Enable paging. 3. Use the code snippet below: private void Form1_Load(object sender, EventArgs e) { this.ordersTableAdapter.Fill(this.nwindDataSet.Orders); bs.DataSource = this.ordersBindingSource; this.radGridView1.DataSource = bs; } BindingSource bs = new BindingSource(); private void radButton1_Click(object sender, EventArgs e) { bs.Filter ="ShipName LIKE '%z%'"; } 4. Navigate to page 80 and click the button. 5. You have only 4 pages available , but you are still positioned on page 80. Workaround: private void radButton1_Click(object sender, EventArgs e) { bs.Filter ="ShipName LIKE '%z%'"; if (this.radGridView1.MasterTemplate.PageIndex>this.radGridView1.MasterTemplate.TotalPages) { this.radGridView1.MasterTemplate.MoveToFirstPage(); } }
Currently one cannot set the column chooser items properties permanently since they are recreated every time the chooser is shown or item is added/removed. Resolution: You can subscribe to the ColumnChooserItemElementCreating event and edit the column chooser items.
To reproduce: Setup RadGridView as follows: this.Grid.MasterTemplate.EnablePaging = true; this.Grid.Columns.Add(""); this.Grid.Columns.Add(""); this.Grid.Columns.Add(""); this.Grid.Columns.Add(""); On a button click add rows: private void Button_Clic9k(object sender, EventArgs e) { for (int i = 0; i < 120; i++) { this.Grid.Rows.AddNew(); } } You will see a vertical scrollbar when it is not needed. Workaround: Wrap the loop in a Begin/EndUpdate calls: private void Button_Clic9k(object sender, EventArgs e) { this.Grid.BeginUpdate(); for (int i = 0; i < 120; i++) { this.Grid.Rows.AddNew(); } this.Grid.EndUpdate(); }
When RadGridView is in right to left mode and the data is grouped, the layout of the items that represent the group field names is incorrect - the close button overlays the text. WORKAROUND: public Form83() { new RadControlSpyForm().Show(); InitializeComponent(); this.radGridView1.GroupByChanged += radGridView1_GroupByChanged; } void radGridView1_GroupByChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e) { foreach (GroupFieldElement fieldElement in this.radGridView1.GridViewElement.GroupPanelElement.GetDescendants( delegate(RadElement element) { return element is GroupFieldElement; }, Telerik.WinControls.TreeTraversalMode.BreadthFirst)) { fieldElement.TextAlignment = ContentAlignment.MiddleRight; } }
To reproduce: DataTable dt = new DataTable(); public Form1() { InitializeComponent(); this.radGridView1.EnableFiltering = true; this.radGridView1.ShowHeaderCellButtons = true; this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID"); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("Title", typeof(string)); dt.Columns.Add("ParentID", typeof(int)); for (int i = 1; i <= 5; i++) { dt.Rows.Add(i, "Parent." + i, 0); } Random rand = new Random(); for (int i = 6; i < 20; i++) { dt.Rows.Add(i, "Child." + i, rand.Next(1, 6)); } for (int i = 20; i < 40; i++) { dt.Rows.Add(i, "SubChild." + i, rand.Next(6, 20)); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; }
To reproduce: 1.Add a RadGridView and add twelve columns at design time. 2.Enable filtering and use the following code: public Form1() { InitializeComponent(); radGridView1.MasterTemplate.MultiSelect = true; } private void Form1_Load(object sender, EventArgs e) { foreach (var column in radGridView1.Columns) { column.Width = 100; } } 3.When you run the application, click over the filtering cell for the 3rd column. Type in some text and click the filter button. As a result the horizontal scroll bar is positioned at right most. Workaround: radGridView1.MouseDown += radGridView1_MouseDown; radGridView1.TableElement.HScrollBar.ValueChanged += HScrollBar_ValueChanged; int scrollBarValue = 0; bool shouldResetValue = false; private void radGridView1_MouseDown(object sender, MouseEventArgs e) { RadElement clickecElement = this.radGridView1.ElementTree.GetElementAtPoint(e.Location); GridFilterRowElement filterRowElement = clickecElement.FindAncestor<GridFilterRowElement>(); GridNewRowElement newRowElement = clickecElement.FindAncestor<GridNewRowElement>(); if (clickecElement is GridFilterRowElement || clickecElement is GridNewRowElement || filterRowElement != null || newRowElement != null) { shouldResetValue = true; } else { shouldResetValue = false; } scrollBarValue = this.radGridView1.TableElement.HScrollBar.Value; } private void HScrollBar_ValueChanged(object sender, EventArgs e) { if (shouldResetValue) { this.radGridView1.TableElement.HScrollBar.Value = scrollBarValue; } }
If one sets AutoSizeRows to true and AllowSearchRow to true the layout of RadGridView throws an exception.