To reproduce: public Form1() { InitializeComponent(); List<Item> items = new List<Item>(); for (int i = 1; i <= 10; i++) { items.Add(new Item(i, "Product" + i, 0.25m * i, i)); } this.radGridView1.DataSource = items; GridViewDecimalColumn col = new GridViewDecimalColumn("Calculated Column"); col.Expression = "Quantity*Price/100"; this.radGridView1.Columns.Add(col); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } public class Item { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public int Quantity { get; set; } public Item(int id, string name, decimal price, int quantity) { this.Id = id; this.Name = name; this.Price = price; this.Quantity = quantity; } } MemoryStream s = new MemoryStream(); private void radButton1_Click(object sender, EventArgs e) { s = new MemoryStream(); this.radGridView1.SaveLayout(s); } private void radButton2_Click(object sender, EventArgs e) { this.radGridView1.LoadLayout(s); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { s.Close(); } Workaround: before loading the layout, clear the columns
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.
To reproduce: - Bind the grid and reset its data source in the CellValueChanged event handler. - Start the application, click in a cell, delete the contents and right click a header cell. - Exception is thrown. Workaround: class MyGridHeaderCellElement : GridHeaderCellElement { public MyGridHeaderCellElement(GridViewColumn col, GridRowElement row) : base(col, row) { } protected override Type ThemeEffectiveType { get { return typeof(GridHeaderCellElement); } } protected override void ShowContextMenu() { if (this.ViewTemplate != null) { base.ShowContextMenu(); } } } private void RadGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) { if (e.CellType == typeof(GridHeaderCellElement)) { e.CellType = typeof(MyGridHeaderCellElement); } }
To reproduce: setup the hierarchy at design time: http://docs.telerik.com/devtools/winforms/gridview/hierarchical-grid/tutorial-binding-to-hierarchical-data Please refer to the attached gif file illustrating the exact steps. NOTE: when the "Object does not match target type" error message is displayed, some of the properties are missing, e.g. MaxLength. Workaround: modify the columns' properties at run time.
To reproduce: private void Form1_Load(object sender, EventArgs e) { this.productsTableAdapter.Fill(this.nwindDataSet.Products); this.radGridView1.EnableFiltering = true; this.radGridView1.ShowHeaderCellButtons = true; this.radGridView1.ShowFilteringRow = false; this.radGridView1.Columns["UnitPrice"].FormatString = "{0:$#,###0.00;-$#,###0.00;$0.00}"; } Workaround: in order to format the cells, use the CellFormatting event. As to the filter popup, use the following approach: this.radGridView1.FilterPopupInitialized += radGridView1_FilterPopupInitialized; private void radGridView1_FilterPopupInitialized(object sender, Telerik.WinControls.UI.FilterPopupInitializedEventArgs e) { RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup; if (popup != null) { popup.MenuTreeElement.TreeView.NodeFormatting -= TreeView_NodeFormatting; popup.MenuTreeElement.TreeView.NodeFormatting += TreeView_NodeFormatting; } } private void TreeView_NodeFormatting(object sender, TreeNodeFormattingEventArgs e) { decimal price; if (decimal.TryParse(e.Node.Text, out price)) { e.NodeElement.ContentElement.Text = string.Format("{0:$#,###0.00;-$#,###0.00;$0.00}", price); } }
To reproduce: Sub New() InitializeComponent() ThemeResolutionService.ApplicationThemeName = "Breeze" Dim dt As New DataTable dt.Columns.Add("Id", GetType(Integer)) dt.Columns.Add("ParentId", GetType(Integer)) dt.Columns.Add("Name", GetType(String)) For index = 1 To 5 dt.Rows.Add(index, 0, "Parent" & index) Next Dim rand As New Random For index = 6 To 25 dt.Rows.Add(index, rand.Next(1, 6), "Parent" & index) Next Me.RadGridView1.Relations.AddSelfReference(Me.RadGridView1.MasterTemplate, "Id", "ParentId") Me.RadGridView1.DataSource = dt Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill Me.RadGridView1.AutoSizeRows = True End Sub
Please refer to the attached project. Workakround: call the BeginEdit method in the RadGridView.Click event.
Add an ExportToXlsx option into the native RadGridView exporting. It has been done for WPF (http://docs.telerik.com/devtools/wpf/controls/radgridview/export/export-xlsx) - why not WinForms. This would avoid the pain of having to implement the export using RadSpreadProcessing.
To reproduce: this.radGridView1.EnableFiltering = true; this.radGridView1.Columns.Add("Test column"); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.Rows.Add("Test "); Workaround: use custom filtering: this.radGridView1.EnableCustomFiltering = true; this.radGridView1.CustomFiltering += radGridView1_CustomFiltering; private void radGridView1_CustomFiltering(object sender, GridViewCustomFilteringEventArgs e) { if (this.radGridView1.FilterDescriptors.Count > 0) { GridViewCellInfo cell = e.Row.Cells[this.radGridView1.FilterDescriptors[0].PropertyName]; e.Visible = cell.Value.ToString().StartsWith(this.radGridView1.FilterDescriptors[0].Value.ToString()); } }
To reproduce: follow the steps defined in the following help article: http://docs.telerik.com/devtools/winforms/gridview/hierarchical-grid/tutorial-binding-to-hierarchical-data Then, add a nested template in the second level. After closing the GridViewTemplate Collection Editor, you will notice that the template is not saved. http://screencast.com/t/7VDYiopuUHn Workaround: setup the hierarchy programmatically : http://docs.telerik.com/devtools/winforms/gridview/hierarchical-grid/binding-to-hierarchical-data-programmatically
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();
One should be able to set the maximum row height when the rows are auto sized and the visual styles are exported.
To reproduce: Open the attached project, select two rows and delete them. Workaround: private void RadGridView1_RowValidating(object sender, Telerik.WinControls.UI.RowValidatingEventArgs e) { if (e.RowIndex != -1) { } }
To reproduce: Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products) Me.CategoriesTableAdapter.Fill(Me.NwindDataSet.Categories) RadGridView1.AutoGenerateHierarchy = True RadGridView1.DataSource = Me.NwindDataSet RadGridView1.DataMember = "Categories" Me.RadGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill Me.RadGridView1.MasterTemplate.Templates(0).AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill Me.RadGridView1.UseScrollbarsInHierarchy = True End Sub Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs) Handles RadGridView1.ViewCellFormatting If e.Row.HierarchyLevel > 0 Then e.CellElement.TableElement.RowHeaderColumnWidth = 100 End If End Sub
To reproduce: make sure only the first row is selected then Shift select row 3. DataTable dt = new DataTable(); dt.Columns.Add("Value", typeof(int)); dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add("Description", typeof(string)); for (int index = 0; index < 15; index++) { dt.Rows.Add(new object[] { index % 5, DateTime.Now.AddSeconds(10), "Index = " + index }); } radGridView1.DataSource = dt; radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.MultiSelect = true; foreach (GridViewColumn col in this.radGridView1.Columns) { ConditionalFormattingObject obj = new ConditionalFormattingObject("Value", ConditionTypes.Equal, col.Index.ToString(), "", true); obj.RowBackColor = Color.SkyBlue; obj.RowForeColor = Color.Red; obj.TextAlignment = ContentAlignment.MiddleRight; obj.ApplyOnSelectedRows = false; this.radGridView1.Columns[0].ConditionalFormattingObjectList.Add(obj); } Workaround: use the CellFormatting event to apply the desired formatting by using the API for overriding theme settings: http://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells http://docs.telerik.com/devtools/winforms/telerik-presentation-framework/override-theme-settings-at-run-time
How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.Columns[0].DisableHTMLRendering = false; this.radGridView1.PrintCellFormatting += radGridView1_PrintCellFormatting; } private void radGridView1_PrintCellFormatting(object sender, Telerik.WinControls.UI.PrintCellFormattingEventArgs e) { e.PrintCell.EnableHtmlTextRendering = true; } private DataTable GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add("Bool", typeof(bool)); dt.Columns.Add("Description", typeof(string)); for (int i = 0; i < 10; i++) { for (int j = 0; j < 5; j++) { dt.Rows.Add(@"<html><b>Name " + j, DateTime.Now.AddDays(i), i % 2 == 0 ? true : false, "Description " + i); } } return dt; } private void radButton1_Click(object sender, EventArgs e) { GridPrintStyle style = new GridPrintStyle(); style.FitWidthMode = PrintFitWidthMode.FitPageWidth; style.PrintGrouping = true; style.PrintSummaries = false; style.PrintHeaderOnEachPage = true; style.PrintHiddenColumns = false; style.CellPadding = new Padding(100, 0, 0, 0); this.radGridView1.PrintStyle = style; this.radGridView1.PrintPreview(); } } Workaround: refer to the attached project
To reproduce: private void Form1_Load(object sender, EventArgs e) { this.productsTableAdapter.Fill(this.nwindDataSet.Products); this.radGridView1.BestFitColumns(BestFitColumnMode.AllCells); } private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) { if (e.CellElement is GridGroupContentCellElement) { e.CellElement.TextWrap = true; } else { e.CellElement.ResetValue(LightVisualElement.TextWrapProperty, ValueResetFlags.Local); } } Workaround: set the AutoSizeColumnsMode property to GridViewAutoSizeColumnsMode.Fill and use the ViewCellFormatting event to wrap the text: private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) { if (e.CellElement is GridGroupContentCellElement) { e.CellElement.TextWrap = true; } else { e.CellElement.ResetValue(LightVisualElement.TextWrapProperty, ValueResetFlags.Local); } }
Please find attached a sample project. 1. Select the new row and activate te editor. 2. Do not enter any value and click outside the new row. The exception is thrown. Workaround: bind directly to the query result: this.radGridView1.DataSource = (from p in context.Customers select p).ToList();
Workaround: instead of using the default alternating row color for the mentioned themes, use the override theme setting in the CellFormatting event: http://www.telerik.com/help/winforms/tpf-override-theme-settings-at-run-time.html private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) { if (e.Row is GridViewDataRowInfo) { if (e.RowIndex % 2 == 0) { e.CellElement.SetThemeValueOverride(LightVisualElement.BackColorProperty, Color.Red, ""); e.CellElement.SetThemeValueOverride(LightVisualElement.DrawFillProperty, true, ""); e.CellElement.SetThemeValueOverride(LightVisualElement.GradientStyleProperty, GradientStyles.Solid, ""); } else { e.CellElement.ResetThemeValueOverride(LightVisualElement.BackColorProperty, ""); e.CellElement.ResetThemeValueOverride(LightVisualElement.DrawFillProperty, ""); e.CellElement.ResetThemeValueOverride(LightVisualElement.GradientStyleProperty, ""); } } }
Currently the Paging functionality does not support server side operations. It should be extended to support them, e.g. with EntityFramework and Telerik Data Access