All event handlers should be made virtual. All controls should be public or have properties.
To reproduce: run the attached sample project. Workaround: set the AutoSizeRows property to false before exporting and set it back to true after the export is completed.
WORKAROUND: 1. Create a custom GridTableElement and override the ProcessColumnEvent method. 2. Create a custom TableViewDefinition and override the CreateViewUIElement to return the custom table element. 3. Assign the custom view definition to the grid's ViewDefinition property public class CustomGridTableElement : GridTableElement { protected override GridViewEventResult ProcessColumnEvent(GridViewColumn column, GridViewEvent eventData) { if (eventData.Info.Id == KnownEvents.PropertyChanged) { RadPropertyChangedEventArgs args = eventData.Arguments[0] as RadPropertyChangedEventArgs; if (args.Property == GridViewColumn.IsVisibleProperty) { ViewElement.UpdateRowsWhenColumnsChanged(); if (this.GridViewElement.AutoSizeRows) { foreach (GridViewRowInfo row in this.ViewTemplate.Rows) { row.Height = -1; } this.UpdateLayout(); this.RowScroller.UpdateScrollRange(); } return null; } } return base.ProcessColumnEvent(column, eventData); } protected override Type ThemeEffectiveType { get { return typeof(GridTableElement); } } } public class CustomTableViewDefinition : TableViewDefinition { public override IRowView CreateViewUIElement(GridViewInfo viewInfo) { return new CustomGridTableElement(); } } this.radGridView1.ViewDefinition = new CustomTableViewDefinition();
To reproduce: DataTable dt = new DataTable(); public Form1() { InitializeComponent(); dt.Columns.Add("Id"); dt.Columns.Add("Name"); dt.Columns.Add("Type"); for (int i = 0; i < 30; i++) { dt.Rows.Add(i, "Item" + i, "Type" + i % 2); } this.radGridView1.DataSource = dt; this.radGridView1.AutoExpandGroups = true; GroupDescriptor descriptor = new GroupDescriptor(); descriptor.GroupNames.Add("Type", ListSortDirection.Ascending); this.radGridView1.GroupDescriptors.Add(descriptor); } private void button1_Click(object sender, EventArgs e) { dt.Rows.Add(30, "Item30", "Type3"); } Workaround: set the AutoExpandGroups property to false and manually expand the groups when a new row is added.
To reproduce: populate the grid with data and use the code snippet below: public Form1() { InitializeComponent(); this.radGridView1.EnablePaging = true; this.radGridView1.AddNewRowPosition = Telerik.WinControls.UI.SystemRowPosition.Bottom; } Select the third page and click the new row at the bottom. The editor is activated as expected but the first page is made current. Workaround: use the CellEditorInitialized event and move to the desired page private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { if (e.Row is GridViewNewRowInfo) { this.radGridView1.MasterTemplate.MoveToPage(2); } }
Please refer to the attached sample project.
To reproduce: public RadForm1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("Name"); for (int i = 0; i < 50; i++) { dt.Rows.Add(i, "Data" + i); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.AutoSizeRows = false; } private void RadForm1_Load(object sender, EventArgs e) { this.radGridView1.Rows[5].MinHeight = 80; this.radGridView1.Rows[5].MaxHeight = 100; } The Min/MaxHeight is not respected even when resizing the row. Workaround: set the Height property.
Description: if you filter a text column with "Does not contains" operator, the produced FilterDescriptors.Expression is "ProductName NOT LIKE '%c%' OR ProductName IS NULL". However, if you try to programmatically add this expression to the RadGridView.FilterDescriptors.Expression property it doesn't filter the grid. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products) Me.RadGridView1.EnableFiltering = True End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Me.RadGridView1.FilterDescriptors.Expression = "ProductName NOT LIKE '%c%' OR ProductName IS NULL" End Sub Workaround: don't set expression but add a FilterDescriptor: http://docs.telerik.com/devtools/winforms/gridview/filtering/setting-filters-programmatically-(simple-descriptors) Dim filter1 As New FilterDescriptor() filter1.[Operator] = FilterOperator.NotContains filter1.Value = "c" filter1.IsFilterEditor = True filter1.PropertyName = "ProductName" Me.RadGridView1.FilterDescriptors.Add(filter1)
To reproduce: - Bind the grid to an object that contains enum property. - Save the layout - Restart the application and load the layout before setting the DataSource of the grid. Workaround: Load the layout after the DataSource is set.
Workaround: create a custom GridDetailViewCellElement Public Class Form1 Sub New() InitializeComponent() AddHandler dgvPatients.CreateCell, AddressOf dgvPatients_CreateCell End Sub Private Sub dgvPatients_CreateCell(sender As Object, e As GridViewCreateCellEventArgs) If e.CellType = GetType(GridDetailViewCellElement) Then e.CellElement = New MyGridDetailViewCellElement(e.Column, e.Row) End If End Sub End Class Public Class MyGridDetailViewCellElement Inherits GridDetailViewCellElement Sub New(column As GridViewColumn, rowElement As GridRowElement) MyBase.New(column, rowElement) End Sub Public Overrides Sub UpdateTabItemsVisibility() If Me.DetailsRow Is Nothing Then Return End If MyBase.UpdateTabItemsVisibility() End Sub End Class
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"); }
Workaround: handle the GridViewPdfExport.CellFormatting event and apply the column`s format string Public Class Form1 Sub New() InitializeComponent() Me.RadGridView1.DataSource = Me.GetData() Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill Dim decimalColumn = DirectCast(Me.RadGridView1.Columns("Money"), GridViewDecimalColumn) decimalColumn.DecimalPlaces = 0 decimalColumn.FormatString = "{0:C0}" Dim dateTimeColumn = DirectCast(Me.RadGridView1.Columns("Date"), GridViewDateTimeColumn) dateTimeColumn.FormatString = "{0:D}" End Sub Private Function GetData() As Object Dim dataTable As New DataTable() dataTable.Columns.Add("Id", GetType(Integer)) dataTable.Columns.Add("Name", GetType(String)) dataTable.Columns.Add("Money", GetType(Decimal)) dataTable.Columns.Add("Date", GetType(DateTime)) For i As Integer = 0 To 999 dataTable.Rows.Add(i, "Name " & i, i * 10, DateTime.Now.AddDays(i)) Next Return dataTable End Function Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim pdfExporter = New GridViewPdfExport(Me.RadGridView1) AddHandler pdfExporter.CellFormatting, AddressOf pdfExporter_CellFormatting Dim renderer = New PdfExportRenderer() Dim fileName As String = "..\..\exported-grid.pdf" pdfExporter.RunExport(fileName, renderer) End Sub Private Sub pdfExporter_CellFormatting(sender As Object, e As PdfExportCellFormattingEventArgs) If e.RowIndex > -1 Then e.CellElement.Text = TryCast(RadDataConverter.Instance.Format(e.Row.Cells(e.ColumnIndex).Value, GetType(String), e.Column), String) End If End Sub End Class
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
Steps to reproduce: 1. Set DPI scale to 150 of all screens 2. Run attached sample 3. The column`s width is not calculated correctly.
How to reproduce: Create a grid with enabled filtering and open the excel-like filter popup of a DateTime column. Workaround: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.EnableFiltering = true; this.radGridView1.ShowFilteringRow = true; this.radGridView1.ShowHeaderCellButtons = true; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.FilterPopupInitialized += RadGridView1_FilterPopupInitialized; } private void RadGridView1_FilterPopupInitialized(object sender, FilterPopupInitializedEventArgs e) { RadDateFilterPopup popup = e.FilterPopup as RadDateFilterPopup; if (popup != null && popup.Width < 300) { popup.Width += 100; popup.Height += 100; } } private object GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Bool", typeof(bool)); dt.Columns.Add("Date", typeof(DateTime)); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "Name " + i, i % 2 == 0, DateTime.Now.AddDays(1)); } return dt; } }
The CustomSorting event should manipulate the pinned rows as well. Thus, the user will be allowed to control the sort order of the pinned rows within the pinned container.
Use attached to reproduce. Workaround: class MyViewDefinition : TableViewDefinition { public override IRowView CreateViewUIElement(GridViewInfo viewInfo) { return new MyTableElement(); } } class MyTableElement : GridTableElement { public override void DpiScaleChanged(SizeF scaleFactor) { if (this.ViewTemplate != null) { base.DpiScaleChanged(scaleFactor); } } protected override Type ThemeEffectiveType { get { return typeof(GridTableElement); } } } //use the above definition like this: radGridView1.ViewDefinition = new MyViewDefinition();
How to reproduce: Check the attached video --> radgridview-filtering.gif Workaround: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableFiltering = true; this.radGridView1.FilterChanging += RadGridView1_FilterChanging; this.radGridView1.FilterChanged += RadGridView1_FilterChanged; } private void RadGridView1_FilterChanged(object sender, GridViewCollectionChangedEventArgs e) { if (clearFiler) { this.radGridView1.FilterDescriptors.Remove((FilterDescriptor)e.NewItems[0]); clearFiler = false; } } bool clearFiler = false; private void RadGridView1_FilterChanging(object sender, GridViewCollectionChangingEventArgs e) { if (e.PropertyName == "Operator" && e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanging) { FilterDescriptor fd = e.OldItems[0] as FilterDescriptor; if (fd != null && (fd.Operator == FilterOperator.IsNull || fd.Operator == FilterOperator.IsNotNull)) { clearFiler = true; } } } private object 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 < 100; i++) { dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i), i % 2 == 0); } return dt; } }