To reproduce: radGridView1.EnableSorting = true; radGridView1.AutoSizeRows = true; radGridView1.ShowGroupPanel = false; radGridView1.EnableGrouping = false; radGridView1.MasterTemplate.AllowColumnChooser = false; radGridView1.MasterTemplate.AllowAddNewRow = false; radGridView1.MasterTemplate.AllowDeleteRow = false; radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.MasterTemplate.AllowCellContextMenu = false; radGridView1.MasterTemplate.AllowColumnHeaderContextMenu = false; radGridView1.Columns.Add(new GridViewTextBoxColumn("key")); radGridView1.Columns.Add(new GridViewTextBoxColumn("value")); radGridView1.Columns.Add(new GridViewCheckBoxColumn { EnableHeaderCheckBox = true, }); var list = new List<KeyValuePair<string, string>>(); list.Add(new KeyValuePair<string, string>("1", "One")); list.Add(new KeyValuePair<string, string>("2", "Two")); radGridView1.DataSource = list; radGridView1.CurrentRow = null;
To reproduce: List<Coordinate> coordinates_ = new List<Coordinate>(); public Form1() { InitializeComponent(); for (int i = 0; i < 10; i++) { coordinates_.Add(new Coordinate(i * 0.25, i * 0.33, i * 0.46)); } this.radGridView1.AutoGenerateColumns = false; string mask = "F2"; this.radGridView1.Columns.Add(CreateDecimalColumn("X", "X", mask)); this.radGridView1.Columns.Add(CreateDecimalColumn("Y", "Y", mask)); this.radGridView1.Columns.Add(CreateDecimalColumn("Z", "Z", mask)); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; SetRows(); } GridViewDataColumn CreateDecimalColumn(string name, string headertext, string mask) { var format = "{0:" + mask + "}"; return new GridViewMaskBoxColumn() { Name = name, HeaderText = headertext, MinWidth = 50, MaskType = MaskType.Numeric, Mask = mask, FormatString = format, DataType = typeof(double), TextAlignment = ContentAlignment.MiddleRight }; } void SetRows() { foreach (var c in coordinates_) { var ri = radGridView1.Rows.AddNew(); ri.Cells["X"].Value = c.X; ri.Cells["Y"].Value = c.Y; ri.Cells["Z"].Value = c.Z; } } public class Coordinate { public double X { get; set; } public double Y { get; set; } public double Z { get; set; } public Coordinate(double x, double y, double z) { this.X = x; this.Y = y; this.Z = z; } } Workaround: private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e) { if (e.EditorType==typeof(RadMaskedEditBoxEditor)) { e.Editor = new RadMaskedEditBoxEditor(); } }
To reproduce: public Form1() { InitializeComponent(); InitializeRadGridView(); this.Size = new System.Drawing.Size(782, 647); radGridView1.DataSource = GetDataSource(); radGridView1.MasterTemplate.ExpandAll(); } private void InitializeRadGridView() { radGridView1.EnableGrouping = false; radGridView1.AllowAddNewRow = false; radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; GridViewDataColumn column = new GridViewTextBoxColumn(); column.FieldName = "Name"; radGridView1.MasterTemplate.Columns.Add(column); GridViewTemplate template = new GridViewTemplate(); template.AllowCellContextMenu = false; template.AllowColumnHeaderContextMenu = false; template.AutoGenerateColumns = false; template.ShowRowHeaderColumn = false; template.ShowColumnHeaders = false; template.AllowAddNewRow = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.Templates.Add(template); GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate, template); relation.ChildColumnNames.Add("Bs"); radGridView1.Relations.Add(relation); column = new GridViewTextBoxColumn(); column.FieldName = "Name"; radGridView1.Templates[0].Columns.Add(column); column = new GridViewImageColumn(); column.MinWidth = column.MaxWidth = 30; radGridView1.Templates[0].Columns.Add(column); radGridView1.Templates[0].AllowRowReorder = true; template = new GridViewTemplate(); template.AllowCellContextMenu = false; template.AllowColumnHeaderContextMenu = false; template.AutoGenerateColumns = false; template.ShowRowHeaderColumn = false; template.ShowColumnHeaders = false; template.AllowAddNewRow = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.Templates[0].Templates.Add(template); relation = new GridViewRelation(radGridView1.Templates[0], template); relation.ChildColumnNames.Add("Cs"); radGridView1.Relations.Add(relation); column = new GridViewTextBoxColumn(); column.FieldName = "Name"; radGridView1.Templates[0].Templates[0].Columns.Add(column); radGridView1.Templates[0].Templates[0].AllowRowReorder = true; } private List<A> GetDataSource() { List<A> list = new List<A>(); A a1 = new A(); a1.Id = 1; a1.Name = "A1"; list.Add(a1); A a2 = new A(); a2.Id = 2; a2.Name = "A2"; list.Add(a2); A a3 = new A(); a3.Id = 3; a3.Name = "A3"; list.Add(a3); B b1 = new B(); b1.Id = 10; b1.Name = "B1"; a1.Bs.Add(b1); B b2 = new B(); b2.Id = 20; b2.Name = "B2"; a1.Bs.Add(b2); B b3 = new B(); b3.Id = 30; b3.Name = "B3"; a1.Bs.Add(b3); B b4 = new B(); b4.Id = 40; b4.Name = "B4"; a2.Bs.Add(b4); B b5 = new B(); b5.Id = 50; b5.Name = "B5"; a3.Bs.Add(b5); C c1 = new C(); c1.Id = 100; c1.Name = "C1"; b1.Cs.Add(c1); b3.Cs.Add(c1); C c2 = new C(); c2.Id = 200; c2.Name = "C2"; b1.Cs.Add(c2); b2.Cs.Add(c2); b2.Cs.Add(c1); C c3 = new C(); c3.Id = 300; c3.Name = "C3"; b1.Cs.Add(c3); b2.Cs.Add(c3); b3.Cs.Add(c3); C c4 = new C(); c4.Id = 400; c4.Name = "C4"; b4.Cs.Add(c4); C c5 = new C(); c5.Id = 500; c5.Name = "C5"; b5.Cs.Add(c5); return list; } } public class A { public int Id { get; set; } public string Name { get; set; } public List<B> Bs { get; set; } public A() { Bs = new List<B>(); } } public class B { public int Id { get; set; } public string Name { get; set; } public List<C> Cs { get; set; } public B() { Cs = new List<C>(); } } public class C { public int Id { get; set; } public string Name { get; set; } } The last row is not fully visible, hence a scroll bar should be shown Workaround: collapse and expand the last row in the grid: radGridView1.MasterTemplate.ExpandAll(); radGridView1.ChildRows[radGridView1.ChildRows.Count - 1].IsExpanded = false; radGridView1.ChildRows[radGridView1.ChildRows.Count - 1].IsExpanded = true;
StackOverFlow exception when the user sorts a GridView control. The exception occurs in the CellValueNeeded method when accessing e.RowIndex. The GridView is in VirtualMode. The error doesn't occur during the initial load of the data.
When RadGridView is in virtual mode, a StackOverflowException occurs if sorting or filtering is performed.
Steps to reproduce: 1) Add RadGridView control 2) Add GridViewTextBoxColumn 2) Enable filtering: this.radGridView1.EnableFiltering = true; 3) Programmatically set filter descriptor: FilterDescriptor filter = new FilterDescriptor(); filter.PropertyName = "TextBoxColumn"; filter.Operator = FilterOperator.IsEqualTo; filter.IsFilterEditor = true; this.radGridView1.FilterDescriptors.Add(filter); Expected result: the default FilterDescriptor is changed from Contains to IsEqual Actual result: can not set the default FilterDescriptor from Contains to IsEqual operator to a TextBoxColumn Workaround: private void OnFilterExpressionChanged(object sender, FilterExpressionChangedEventArgs e) { GridViewTemplate owner = sender as GridViewTemplate; List<string> filterExpressions = new List<string>(); for (int i = 0; i < owner.FilterDescriptors.Count; i++) { FilterDescriptor descriptor = owner.FilterDescriptors[i]; string expression = null; CompositeFilterDescriptor compositeFilterDescriptor = descriptor as CompositeFilterDescriptor; if (compositeFilterDescriptor != null) { foreach (FilterDescriptor filterDescriptor in compositeFilterDescriptor.FilterDescriptors) { if (string.IsNullOrEmpty(filterDescriptor.PropertyName) || owner.Columns[filterDescriptor.PropertyName] == null) { continue; } } expression = CompositeFilterDescriptor.GetCompositeExpression(compositeFilterDescriptor); } else { if (string.IsNullOrEmpty(descriptor.PropertyName) || owner.Columns[descriptor.PropertyName] == null) { continue; } if (descriptor.Value == null && (descriptor.Operator == FilterOperator.IsNotEqualTo || descriptor.Operator == FilterOperator.IsEqualTo)) { expression = string.Empty; } else { expression = descriptor.Expression; } } if (!string.IsNullOrEmpty(expression)) { filterExpressions.Add(expression); } } string logicalOperator = (owner.FilterDescriptors.LogicalOperator == FilterLogicalOperator.And) ? " AND " : " OR "; string resultExpression = String.Join(logicalOperator, filterExpressions.ToArray()); e.FilterExpression = resultExpression; }
When AutoSizeRows = true and there is column with multiline text values, when hiding that column - shrink row height accordingly.
To reproduce: public RadForm1() { InitializeComponent(); DataTable master = new DataTable(); master.Columns.Add("ID", typeof(int)); master.Columns.Add("F_ID", typeof(int)); master.Columns.Add("test", typeof(string)); DataTable child = new DataTable(); child.Columns.Add("F_ID", typeof(int)); child.Columns.Add("test", typeof(string)); child.Columns.Add("CheckBox", typeof(bool)); for (int i = 0; i < 10; i++) { master.Rows.Add(i, i , "Row " + i); child.Rows.Add(i , "Child " + i, true); } radGridView1.DataSource = master; GridViewTemplate template = new GridViewTemplate(); template.DataSource = child; radGridView1.MasterTemplate.Templates.Add(template); GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate); relation.ChildTemplate = template; relation.RelationName = "Test"; relation.ParentColumnNames.Add("F_ID"); relation.ChildColumnNames.Add("F_ID"); radGridView1.Relations.Add(relation); this.Load += RadForm1_Load; } void RadForm1_Load(object sender, EventArgs e) { GridViewCheckBoxColumn col = radGridView1.MasterTemplate.Templates[0].Columns[2] as GridViewCheckBoxColumn; col.EnableHeaderCheckBox = true; } - Expand some rows and click on header check box.
Saving a form with RadGridView produces the following error at design time: Code generation for property "PrintCellPaint" failed. We isolated the following steps which reproduce the issue: 1. Drag and drop RadPageView on the form. Add 2 pages. 2. Add a RadGridView to one of the pages. 3. Saved and opened the form. 4. Select the other page and save the form. case #1: If the grid is empty - Code generation for property 'PrintCellPaint' failed. Error was: 'Object does not match type.' case #2: If the grid is data bound - Code generation for property 'PropertyChanging' failed. Error was: 'Object does not match type.' The same errors if you use RadDock with tabbed documents.
It does not matter the type of the control that we want to move the focus on as well as if it was RadControl or not To reproduce: private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e) { e.Cancel = true; // Some other control to move the focus on this.textBox1.Focus(); } Workaround: Before cancelling the event set the value of the active editor to the current cell value private void radGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e) { this.radGridView1.ActiveEditor.Value = e.Row.Cells[e.Column.Name].Value; e.Cancel = true; // Some other control to move the focus on this.textBox1.Focus(); }
The conditional formatting collection get deleted after closing the property builder. To reproduce : Add a gridview with a datasource. Open property builder Select a column Advance -> ConditionalFormattingObjectList Add a expression, set a name Press Ok If you click the ConditionalFormattingObjectList, you can see the expression If you click close the Property Builder, the list is not saved when you open it again.
To reproduce: - Enable the search row in the grid. - Enter some text in the search text box in order to mark some rows. - Refresh the master template. - Notice that the text is cleared, but the formatting remains. Workaround, use the following custom cell: class MyGridSearchCellElement : GridSearchCellElement { public MyGridSearchCellElement(GridViewColumn column, GridRowElement row) :base (column, row) { } bool performSearch = true; protected override void SyncLabelText() { //base.SyncLabelText(); GridViewSearchRowInfo searchRow = this.RowInfo as GridViewSearchRowInfo; if (searchRow == null) { return; } performSearch = false; string searchCriteria = typeof(GridViewSearchRowInfo).GetField("searchCriteria", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(searchRow).ToString(); if (string.IsNullOrEmpty(searchCriteria)) { this.SearchTextBox.Text = String.Empty; this.SearchTextBox.SearchInfoLabel.Text = String.Empty; } else { this.SearchTextBox.Text = searchCriteria; this.SearchTextBox.SearchInfoLabel.Text = string.Format("{0} {1} {2}", searchRow.CurrentResultIndex + 1, Telerik.WinControls.UI.Localization.RadGridLocalizationProvider.CurrentProvider.GetLocalizedString(Telerik.WinControls.UI.Localization.RadGridStringId.SearchRowResultsOfLabel), searchRow.CurrentSearchResultsCount); } performSearch = true; } protected override void Search() { if (!performSearch) { return; } base.Search(); } } To put it in action, use the CreateCell event of RadGridView: void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) { if (e.CellType == typeof( GridSearchCellElement)) { e.CellElement = new MyGridSearchCellElement(e.Column, e.Row); } }
RADGRIDVIEW Extend it with the following localization string ids: – RadGridStringId.FilterMenuSelectionTrue – RadGridStringId.FilterMenuSelectionFalse Resolution: The mentioned strings are not predefined strings within RadGridView. They come from the values of the column being filtered (e.g. if the column is a checkbox column, all values are either True or False). Therefore, to localize them, you need to use a ValueConverter and override the conversion to string: this.radGridView1.Columns[3].DataTypeConverter = new MyConverter(); class MyConverter : BooleanConverter { public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { if (Object.Equals(value, "True") || (value is bool && (bool)value)) return "Yes"; if (Object.Equals(value, "False") || (value is bool && !(bool)value)) return "No"; } return base.ConvertTo(context, culture, value, destinationType); } }
To reproduce: string fileName = @"..\..\..\exported" + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".xlsx"; SpreadExport spreadExporter = new SpreadExport(radGridView1); spreadExporter.ExportVisualSettings = false; spreadExporter.RunExport(fileName); Workaround: spreadExporter.WorkbookCreated += spreadExporter_WorkbookCreated; private void spreadExporter_WorkbookCreated(object sender, WorkbookCreatedEventArgs e) { Telerik.Windows.Documents.Spreadsheet.PropertySystem.CellStyle defaultStyle = e.Workbook.Styles.Add("DefaultStyle"); defaultStyle.FontSize = Telerik.Windows.Documents.Spreadsheet.Utilities.UnitHelper.PointToDip(11); Telerik.Windows.Documents.Spreadsheet.Model.Worksheet sheet = e.Workbook.Worksheets.First(); sheet.Cells[0, 0, sheet.UsedCellRange.RowCount, sheet.UsedCellRange.ColumnCount].SetStyleName("DefaultStyle"); sheet.Columns[sheet.UsedCellRange].AutoFitWidth(); }
To reproduce use the following snippets in the CellFormatting event of the exporter: ThemableColor red = new ThemableColor(System.Windows.Media.Colors.Red); CellBorders redBorders = new CellBorders(new CellBorder(CellBorderStyle.Medium, red)); e.CellStyleInfo.Borders = redBorders; or ThemableColor red = new ThemableColor(System.Windows.Media.Colors.Red); CellBorders fourBorders = new CellBorders(); fourBorders.Top = new CellBorder(CellBorderStyle.Thin, red); fourBorders.Bottom = new CellBorder(CellBorderStyle.Thin, red); fourBorders.Right = new CellBorder(CellBorderStyle.Thin, red); fourBorders.Left = new CellBorder(CellBorderStyle.Thin, red); e.CellStyleInfo.Borders = fourBorders;
Hello, I succeed to reproduce the GridViewComboboxColumn exception in this forum post: http://www.telerik.com/forums/nullreferenceexception-4a6181b2453b#cwDrbIqzp0CPxcgh90b4rQ I attach a sample project, the database (SQL Server 2012 Express) and a video from the exception. To reproduce: - Run the project, - Sort the column "Állapot" descending. - Click on column and drop down the list. - Choose an another value, and click very fast twice. On a slow PC is much easier to reproduce the issue. The important thing, that you need select a value from the combobox and select another row very fast. (See the attached video) I use the latest Trial version of Winforms. If you have any question, please contact me. Best Regards, László Workaround: Private Sub gridMunkak_CreateCell(sender As Object, e As GridViewCreateCellEventArgs) Handles gridMunkak.CreateCell If e.CellType = GetType(GridComboBoxCellElement) Then e.CellElement = New MyGridComboBoxCellElement(e.Column, e.Row) End If End Sub Public Class MyGridComboBoxCellElement Inherits GridComboBoxCellElement Public Sub New(column As GridViewColumn, row As GridRowElement) MyBase.New(column, row) End Sub Public Overrides Sub SetContent() If Me.ColumnInfo IsNot Nothing Then MyBase.SetContent() End If End Sub Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(GridComboBoxCellElement) End Get End Property End Class
To reproduce: 1. Add a RadGridView and a RadButton. 2. Populate the grid with data and call the BestFitColumns( BestFitColumnMode.AllCells) method (or resize the columns). 3. Set its RightToLeft property to Windows.Forms.RightToLeft.Yes. 3. In the RadButton.Click event handler call the RadGridView.PrintPreview(). As a result the columns are shrunk. Please see the attached gif file. Workaround: Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Me.RadGridView1.BeginUpdate() Me.RadGridView1.PrintPreview() Me.RadGridView1.EndUpdate() Me.RadGridView1.BestFitColumns(BestFitColumnMode.AllCells) End Sub
To reproduce: - Create a custom column that uses RadTextBoxControlElement as permanent editor. - Add the column to the grid. - Scroll the grid so the custom column is not visible. - Put the the grid in edit mode and change the current cell. Workaround: - Disable the IME support: public class MyRadTextBoxControlElement : RadTextBoxControlElement { protected override Type ThemeEffectiveType { get { return typeof(RadTextBoxControlElement); } } protected override void OnLoaded() { this.InvalidateMeasure(); } }