To reproduce: public Form1() { InitializeComponent(); this.radGridView1.Columns.Add("Name"); this.radGridView1.Columns.Add("ID"); this.radGridView1.RowsChanged += radGridView1_RowsChanged; } private void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e) { Console.WriteLine(e.Action); if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add) { GridViewRowInfo row = e.NewItems[0] as GridViewRowInfo; row.Cells["ID"].Value = this.radGridView1.Rows.Count; } } private void radButton1_Click(object sender, EventArgs e) { this.radGridView1.Rows.Add("Item" + this.radGridView1.Rows.Count); } Note: the first firing of the RowsChanged event used to be with Action=Add.
Please refer to the attached sample project.
Workaround: change the name of the column this.radGridView1.Columns["Table:Name"].Name = "Table|Name";
When you set a RadGridView's SelectionMode to GridViewSelectionMode.CellSelect and then you highlight full rows by using the row header, the SelectedRows collection is empty. Telerik support informed me this is "as expected" and that I should use "SelectedCells" collection when using the CellSelect Mode. While this is a decent workaround I don't see why SelectedRows collection can't be filled when the entire row is actually highlighted.
Create a DataTable with columns Column1, Column2, Column3, Column4, Column5, and bound to RadGridView. Create a second DataTable with columns Column1, Column2a, Column3, Column4, Column5, and re-bind the RadGridView to this DataTable. Instead of the columns appearing in the same order as they are in the second DataTable, they show up as Column1, Column3, Column4, Column5, Column2a in the RadGridView.
To reproduce: GridViewImageColumn imageColumn = new GridViewImageColumn(); imageColumn.Name = "ImageColumn"; imageColumn.FieldName = "ImageColumn"; imageColumn.HeaderText = "Picture"; radGridView1.MasterTemplate.Columns.Add(imageColumn); List<classBinding> databinding = new List<classBinding>(); for (int i = 0; i < 35000; i++) { databinding.Add(new classBinding() { ImageColumn = Properties.Resources.Alarm2, }); } radGridView1.DataSource = databinding; public class classBinding { public System.Drawing.Bitmap ImageColumn { get; set; } }
There should be a convenient and more straightforward API for accessing the TableElement of a child gridview. Currently, the API is: void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { if (e.CellElement is GridDetailViewCellElement) { ((GridDetailViewCellElement)e.CellElement).ChildTableElement.RowHeight = 50; } }
Steps to reproduce: - create a winforms project - create form (normal windows form, not telerik form) - create radgridview from toolbox - right click and open property builder - select mastertemplate - set viewdefinition = columngroups view - add 3-4 columns (textbox, combobox, etc...) - click ok button at the property builder - right click on the radgridview and open the property builder - rename the name and the header text of the first column - click ok button at the property builder
To reproduce: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.CategoriesTableAdapter.Fill(Me.NwindDataSet.Categories) Me.RadGridView1.DataSource = Me.CategoriesBindingSource Dim viewDef As New ColumnGroupsViewDefinition Dim group1 = New GridViewColumnGroup() Dim row1 = New GridViewColumnGroupRow group1.Rows.Add(row1) row1.ColumnNames.Add("CategoryID") row1.ColumnNames.Add("CategoryName") viewDef.ColumnGroups.Add(group1) Dim group2 = New GridViewColumnGroup() Dim row2 = New GridViewColumnGroupRow group2.Rows.Add(row2) row2.ColumnNames.Add("Description") row2.ColumnNames.Add("Picture") viewDef.ColumnGroups.Add(group2) Me.RadGridView1.ViewDefinition = viewDef End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Console.WriteLine("BEFORE >>") For Each col As GridViewColumn In Me.RadGridView1.Columns Console.WriteLine(col.Name & " >> " & col.Width ) Next Dim style As New GridPrintStyle() style.FitWidthMode = PrintFitWidthMode.FitPageWidth Me.RadGridView1.PrintStyle = style Me.RadGridView1.PrintPreview() Console.WriteLine("AFTER >>") For Each col As GridViewColumn In Me.RadGridView1.Columns Console.WriteLine(col.Name & " >> " & col.Width) Next End Sub IMPORTANT: If you resize one of the columns at run time before calling the PrintPreview method, the columns' width is restored. In addition, if you call the PrintPreview method without resizing the columns before that, close the dialog and hide one of the columns by using the default context menu, the columns' width for the visible columns is enlarged. Workaround: you can get the columns width by using the ColumnGroupRowLayout: Dim rowLayout As ColumnGroupRowLayout = TryCast(Me.RadGridView1.TableElement.ViewElement.RowLayout, ColumnGroupRowLayout) For Each col As GridViewColumn In Me.RadGridView1.Columns Dim info As ColumnGroupsCellArrangeInfo = rowLayout.GetColumnData(col) Debug.WriteLine(col.Name & " >> " & info.Bounds.Width) Next
To reproduce: - Add DateTime column and set the RowHeight to 20. - Set the theme to Windows7. - The text is not visible when the editor is shown. Workaround: private void RadGridView2_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDateTimeEditor editor = e.ActiveEditor as RadDateTimeEditor; if (editor != null) { var element = editor.EditorElement as RadDateTimeEditorElement; element.Font = new Font("Segoe UI", 8, FontStyle.Regular); element.Children[1].Visibility = ElementVisibility.Collapsed; element.TextBoxElement.ShowBorder = false; element.TextBoxElement.TextBoxItem.HostedControl.MinimumSize = new Size(0, 12); } }
To reproduce: please refer to the attached sample project. 1. Edit the CommonInt property for the first child row. 2. Edit the CommonInt property for the second child row. Workaround: Add the grid programmatically at run time. Second Workaround: this.radGridView1.CellValueChanged+=radGridView1_CellValueChanged; private void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e) { e.Column.OwnerTemplate.Refresh(e.Column); }
How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetSampleData(); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableFiltering = true; this.radGridView1.ShowFilteringRow = false; this.radGridView1.ShowHeaderCellButtons = true; } private DataTable GetSampleData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(double)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("IsValid", typeof(bool)); dt.Columns.Add("Date", typeof(DateTime)); for (int i = 0; i < 115; i++) { dt.Rows.Add(((double)i * 5 / 7) * 3, "Name " + i, i % 2 == 0, DateTime.Now.AddDays(i)); } return dt; } } Workaround specify decimal as the type of the column in the DataTable object or clone the DataTAble object and change the type of the column: public partial class Form1 : Form { public Form1() { InitializeComponent(); DataTable dt = this.GetSampleData(); DataTable dtCloned = dt.Clone(); dtCloned.Columns[0].DataType = typeof(decimal); foreach (DataRow row in dt.Rows) { dtCloned.ImportRow(row); } this.radGridView1.DataSource = dtCloned; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableFiltering = true; this.radGridView1.ShowFilteringRow = false; this.radGridView1.ShowHeaderCellButtons = true; } private DataTable GetSampleData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(double)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("IsValid", typeof(bool)); dt.Columns.Add("Date", typeof(DateTime)); for (int i = 0; i < 115; i++) { dt.Rows.Add(((double)i * 5 / 7) * 3, "Name " + i, i % 2 == 0, DateTime.Now.AddDays(i)); } return dt; } }
To reproduce: private void Form1_Load(object sender, EventArgs e) { this.productsTableAdapter.Fill(this.nwindDataSet.Products); this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories); this.radGridView1.DataSource = this.productsBindingSource; GridViewMultiComboBoxColumn col = new GridViewMultiComboBoxColumn(); col.DataSource = this.categoriesBindingSource; col.MinWidth = 200; col.DisplayMember = "CategoryName"; col.ValueMember = "CategoryID"; this.radGridView1.Columns.Add(col); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.CellValueChanged += radGridView1_CellValueChanged; } private void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e) { RadMessageBox.Show("CellValueChanged. Value >> " + e.Value.ToString()); }
Selected rows/cells of RadGridView should not be exporting with their selected visual styles and this is why when the export starts all selected rows are cleared. At the end of export selection is restored. This is the reason Validating/ed and SelectionChanged events are fired when exporting with RadGridView exports. Workaround: Unsubscribe from these events before the export starts and subscribe to them again when export operation is completed. this.radGridView1.RowValidating -= radGridView1_RowValidating; this.radGridView1.SelectionChanged -= radGridView1_SelectionChanged; // Export ExportToExcelML excelMLExporter = new ExportToExcelML(this.radGridView1); excelMLExporter.ExportVisualSettings = true; excelMLExporter.RunExport(fileName); this.radGridView1.RowValidating += radGridView1_RowValidating; this.radGridView1.SelectionChanged += radGridView1_SelectionChanged;
To reproduce: populate RadGridView with data and use the following code snippet: Me.RadGridView1.TableElement.TableHeaderHeight = 60 RadGridView1.PrintPreview() Workaround: Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Me.RadGridView1.TableElement.TableHeaderHeight = 60 Dim printStyle As GridPrintStyle = New GridPrintStyle(RadGridView1) Dim renderer As CustomTableViewDefinitionPrintRenderer = New CustomTableViewDefinitionPrintRenderer(RadGridView1) printStyle.PrintRenderer = renderer RadGridView1.PrintStyle = printStyle RadGridView1.PrintPreview() End Sub Public Class CustomTableViewDefinitionPrintRenderer Inherits TableViewDefinitionPrintRenderer Public Sub New(grid As RadGridView) MyBase.New(grid) End Sub Private Function GetRowLayout(row As GridViewRowInfo, fitWidthMode As PrintFitWidthMode, _ hierarchyIndent As Integer, drawArea As Rectangle) As TableViewRowLayout Dim hashKey As Integer = row.ViewTemplate.GetHashCode() + row.HierarchyLevel Dim fi As FieldInfo = GetType(TableViewDefinitionPrintRenderer).GetField("rowLayouts", BindingFlags.NonPublic Or BindingFlags.Instance) Dim rowLayouts As Dictionary(Of Integer, TableViewRowLayout) = fi.GetValue(Me) If rowLayouts.ContainsKey(hashKey) Then Return rowLayouts(hashKey) End If Dim table As GridTableElement = TryCast(row.ViewTemplate.ViewDefinition.CreateViewUIElement(row.ViewInfo), GridTableElement) table.Initialize(Me.GridView.GridViewElement, row.ViewInfo) table.RowHeight = Me.GridView.TableElement.RowHeight table.TableHeaderHeight = Me.GridView.TableElement.TableHeaderHeight Me.GridView.ElementTree.ApplyThemeToElement(table) Dim rowLayout As New TableViewRowLayout() rowLayout.Context = GridLayoutContext.Printer rowLayout.Initialize(table) Dim systemWidth As Integer = 0 For Each c As GridViewColumn In rowLayout.RenderColumns If TypeOf c Is GridViewRowHeaderColumn OrElse TypeOf c Is GridViewIndentColumn Then systemWidth += rowLayout.GetColumnWidth(c) End If Next Me.GridView.BeginUpdate() Dim mode As GridViewAutoSizeColumnsMode = rowLayout.ViewTemplate.AutoSizeColumnsMode If fitWidthMode = PrintFitWidthMode.FitPageWidth Then Dim state As ColumnsState = Me.SaveColumnsState(rowLayout.ViewTemplate) rowLayout.ViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill Dim groupLevel As Integer = If(row.Group IsNot Nothing, row.Group.Level + 1, 0) rowLayout.MeasureRow(New SizeF(drawArea.Width + systemWidth - ((row.HierarchyLevel - groupLevel) * hierarchyIndent), drawArea.Height)) Me.RestoreColumnsState(state) Else rowLayout.ViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None rowLayout.MeasureRow(New SizeF(Me.GridView.Width, Me.GridView.Height)) End If rowLayout.ViewTemplate.AutoSizeColumnsMode = mode Me.GridView.EndUpdate(False) rowLayouts.Add(hashKey, rowLayout) Return rowLayout End Function Public Overrides Sub DrawPage(traverser As PrintGridTraverser, drawArea As Rectangle, _ graphics As Graphics, settings As GridPrintSettings, pageNumber As Integer) Dim fi As FieldInfo = GetType(TableViewDefinitionPrintRenderer).GetField("currentPage", BindingFlags.Instance Or BindingFlags.NonPublic) Dim currentPage As Integer = fi.GetValue(Me) Dim skipPage As Boolean = currentPage <> pageNumber Dim drawAreaHeight As Integer = drawArea.Height Dim currentX As Integer = drawArea.X Dim currentY As Integer = drawArea.Y Dim rowLayout As TableViewRowLayout = Me.GetRowLayout(Me.GridView.MasterView.TableHeaderRow, _ settings.FitWidthMode, settings.HierarchyIndent, drawArea) rowLayout.IgnoreColumnVisibility = settings.PrintHiddenColumns Dim systemWidth As Integer = 0 For Each c As GridViewColumn In rowLayout.RenderColumns If TypeOf c Is GridViewRowHeaderColumn OrElse TypeOf c Is GridViewIndentColumn Then systemWidth += rowLayout.GetColumnWidth(c) End If Next Dim rowWidth As Integer = CInt(rowLayout.DesiredSize.Width) - systemWidth If settings.FitWidthMode = PrintFitWidthMode.NoFitCentered Then currentX += ((drawArea.Width - rowWidth) / 2) End If Dim fi2 As FieldInfo = GetType(TableViewDefinitionPrintRenderer).GetField("firstPage", _ BindingFlags.Instance Or BindingFlags.NonPublic) Dim firstPage As Integer = fi2.GetValue(Me) If ((Me.GridView.ShowColumnHeaders AndAlso (firstPage AndAlso pageNumber = 1)) OrElse settings.PrintHeaderOnEachPage) _ AndAlso Not settings.PrintHierarchy Then Me.PrintRow(Me.GridView.MasterView.TableHeaderRow, rowLayout, settings, currentX, currentY, graphics, _ drawArea) Dim rowHeight As Integer = Me.GetDataRowHeight(Me.GridView.MasterView.TableHeaderRow, rowLayout) + Me.GridView.TableElement.RowSpacing currentY += rowHeight drawAreaHeight -= rowHeight End If fi2.SetValue(Me, False) Dim skipPageCurrentY As Integer = currentY Dim row As GridViewRowInfo = Nothing If Me.PrintPages.Count > 0 AndAlso Not settings.PrintHierarchy Then row = traverser.Current End If Dim firstRow As Boolean = True While traverser.MoveNext() If Not (TypeOf traverser.Current Is GridViewDataRowInfo OrElse TypeOf traverser.Current Is GridViewGroupRowInfo OrElse _ TypeOf traverser.Current Is GridViewSummaryRowInfo OrElse (TypeOf traverser.Current Is GridViewTableHeaderRowInfo _ AndAlso settings.PrintHierarchy)) Then Continue While End If Dim hierarchyRow As GridViewHierarchyRowInfo = TryCast(traverser.Current, GridViewHierarchyRowInfo) If hierarchyRow IsNot Nothing AndAlso hierarchyRow.Views.Count > 0 Then Select Case settings.ChildViewPrintMode Case ChildViewPrintMode.PrintFirstView hierarchyRow.ActiveView = hierarchyRow.Views(0) Exit Select Case ChildViewPrintMode.PrintCurrentlyActiveView 'Do nothing the view is already selected Exit Select Case ChildViewPrintMode.SelectViewToPrint Dim e As New ChildViewPrintingEventArgs(hierarchyRow.Views.IndexOf(hierarchyRow.ActiveView), hierarchyRow) Me.OnChildViewPrinting(e) hierarchyRow.ActiveView = hierarchyRow.Views(e.ActiveViewIndex) Exit Select End Select End If rowLayout = Me.GetRowLayout(traverser.Current, settings.FitWidthMode, settings.HierarchyIndent, drawArea) Dim rowHeight As Integer = 0 If TypeOf traverser.Current Is GridViewGroupRowInfo Then rowHeight = Me.GetRowSize(traverser.Current, rowLayout).Height Else rowHeight = Me.GetDataRowHeight(traverser.Current, rowLayout) End If If (currentY + rowHeight >= drawArea.Bottom OrElse skipPageCurrentY + rowHeight >= drawArea.Bottom) AndAlso Not firstRow Then traverser.MovePrevious() skipPageCurrentY = currentY skipPage = currentPage <> pageNumber fi.SetValue(Me, currentPage + 1) If skipPage Then Continue While Else Exit While End If End If If TypeOf traverser.Current Is GridViewGroupRowInfo Then If settings.PrintGrouping Then If currentPage = pageNumber Then Me.PrintRowWideCell(traverser.Current, rowLayout, settings, currentX, currentY, graphics) currentY += rowHeight + Me.GridView.TableElement.RowSpacing Else skipPageCurrentY += rowHeight + Me.GridView.TableElement.RowSpacing End If End If Else If TypeOf traverser.Current Is GridViewSummaryRowInfo AndAlso Not settings.PrintSummaries Then Continue While End If If currentPage = pageNumber Then Me.PrintRow(traverser.Current, rowLayout, settings, currentX, currentY, graphics, _ drawArea) currentY += rowHeight + Me.GridView.TableElement.RowSpacing Else skipPageCurrentY += rowHeight + Me.GridView.TableElement.RowSpacing End If End If If drawAreaHeight < rowHeight AndAlso firstRow Then fi.SetValue(Me, currentPage + 1) Exit While End If firstRow = False End While If Me.PrintPages.Count > 0 AndAlso Not settings.PrintHierarchy Then If currentY + Me.GetDataRowHeight(traverser.Current, rowLayout) < drawArea.Bottom OrElse _ skipPageCurrentY + Me.GetDataRowHeight(traverser.Current, rowLayout) < drawArea.Bottom Then fi.SetValue(Me, currentPage + 1) End If Me.CurrentPrintPage += 1 Me.CurrentPrintPage = Me.CurrentPrintPage Mod Me.PrintPages.Count If Me.CurrentPrintPage > 0 Then If row Is Nothing Then traverser.Reset() Else traverser.GoToRow(row) End If End If End If End Sub End Class
To reproduce: 1.Set the GridView template's ViewDefinition to ColumnGroups 2.Add a new column 3.Delete the column 4.Add another new column. The PropertyBuilder closes and it is not possible to open the Smart Tag of RadGridView anymore. Please refer to the attached gif file. Workaround: The issue is caused by a remaining reference to a deleted column. When using the RadGridView PropertyBuilder and a column is added to ColumnGroupsViewDefinition, once the column is deleted from RadGridView (via the Property Builder) the code for adding the column in the ColumnGroupsViewDefinition remains, and this causes further designer instability with the Property Builder. To handle this scenario there are two options: 1. When a column is deleted via Property Builder, and this column was part of ColumnGroupsViewDefinition, open the Designer.cs/vb file, locate the line that adds this column to a ColumnNames collection and delete it. It should be something like: gridViewColumnGroupRow3.ColumnNames.Add("column1"); - where "column1" is the name of the deleted column 2. Instead of using the Property Builder to build the ColumnGroupsViewDefinition, build it programmatically.
To reproduce: public class CustomGridViewCheckBoxColumn : GridViewCheckBoxColumn { } CustomGridViewCheckBoxColumn col = new CustomGridViewCheckBoxColumn(); this.radGridView1.Columns.Add(col); this.radGridView1.EnableFiltering = true; 1. Click the filter button and select "Custom" 2. Close the dialog. Workaround: this.radGridView1.CreateCompositeFilterDialog += radGridView1_CreateCompositeFilterDialog; private void radGridView1_CreateCompositeFilterDialog(object sender, GridViewCreateCompositeFilterDialogEventArgs e) { e.Dialog = new CustomCompositeFilterForm(); } public class CustomCompositeFilterForm : CompositeFilterForm { public override void Initialize(GridViewDataColumn dataColumn, FilterDescriptor filterDescriptor, bool useTypedEditors) { base.Initialize(dataColumn, filterDescriptor, useTypedEditors); if (dataColumn is GridViewCheckBoxColumn) { RadGroupBox groupBox = this.Controls[0] as RadGroupBox; groupBox.Controls.Remove(this.RightEditor); groupBox.Controls.Remove(this.LeftEditor); MethodInfo mi = typeof(CompositeFilterForm).GetMethod("InitializeCheckBoxEditors", BindingFlags.Instance | BindingFlags.NonPublic); mi.Invoke(this, null); } } }
To reproduce: use the following code snippet and enter in the filter row one of the row values as it is shown in the screenshot: this.radGridView1.EnableFiltering = true; GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn("DateTimeColumn"); dateTimeColumn.Format = DateTimePickerFormat.Custom; dateTimeColumn.CustomFormat = "dd/MM/yyyy HH:mm:ss"; radGridView1.MasterTemplate.Columns.Add(dateTimeColumn); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < 10; i++) { this.radGridView1.Rows.Add(DateTime.Now.AddDays(i)); } Workaround: custom filtering: http://docs.telerik.com/devtools/winforms/gridview/filtering/custom-filtering
To reproduce: 1. Run the attached application. 2. Click into the cell in Column One and expand the combo box 3. While the combo box is still expanded, right click on any header cell in the grid Step 3 should result in a NullReferenceException Workaround: Friend Class MyGridHeaderCellElement Inherits GridHeaderCellElement Public Sub New(ByVal col As GridViewColumn, ByVal row As GridRowElement) MyBase.New(col, row) End Sub Protected Overrides Sub ShowContextMenu() If Me.ViewTemplate IsNot Nothing Then MyBase.ShowContextMenu() End If End Sub Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(GridHeaderCellElement) End Get End Property End Class Private Sub radGridView1_CreateCell(ByVal sender As Object, ByVal e As GridViewCreateCellEventArgs) If Object.ReferenceEquals(e.CellType, GetType(GridHeaderCellElement)) Then e.CellType = GetType(MyGridHeaderCellElement) End If End Sub