To reproduce: BindingList<Item> items = new BindingList<Item>(); public Form1() { InitializeComponent(); Item dataItem1 = new Item(1); dataItem1.Name = "Cat"; dataItem1.GroupName = "Animal"; dataItem1.GroupSortPriority = 2; items.Add(dataItem1); Item dataItem2 = new Item(2); dataItem2.Name = "Kitten"; dataItem2.GroupName = "Animal"; dataItem2.GroupSortPriority = 2; dataItem2.ParentIndex = 1; items.Add(dataItem2); Item dataItem3 = new Item(3); dataItem3.Name = "Trout"; dataItem3.GroupName = "Fish"; dataItem3.GroupSortPriority = 1; items.Add(dataItem3); radGridView1.Relations.AddSelfReference(radGridView1.MasterTemplate, "Index", "ParentIndex"); radGridView1.DataSource = items; } public class Item { public Item(int index) { Index = index; } public int Index { get; private set; } public int ParentIndex { get; set; } public string Name { get; set; } public string GroupName { get; set; } public int GroupSortPriority { get; set; } } public class GridGroupComparer : IComparer<Group<GridViewRowInfo>> { public GridGroupComparer() { } public int Compare( Group<GridViewRowInfo> x, Group<GridViewRowInfo> y) { if (null == x.Key || null == y.Key) return 1; GridViewRowInfo xGridViewRowInfo = x.DefaultIfEmpty(null).First(); GridViewRowInfo yGridViewRowInfo = y.DefaultIfEmpty(null).First(); if (null == xGridViewRowInfo || null == yGridViewRowInfo) return x.Key.GetHashCode().CompareTo(y.Key.GetHashCode()); Item xGridRowDataItem = xGridViewRowInfo.DataBoundItem as Item; Item yGridRowDataItem = yGridViewRowInfo.DataBoundItem as Item; if (null == xGridRowDataItem || null == yGridRowDataItem) return x.Key.GetHashCode().CompareTo(y.Key.GetHashCode()); if (xGridRowDataItem.GroupSortPriority > yGridRowDataItem.GroupSortPriority) return 1; if (xGridRowDataItem.GroupSortPriority < yGridRowDataItem.GroupSortPriority) return -1; return 0; } } private void Form1_Load(object sender, EventArgs e) { GridGroupComparer groupComparer = new GridGroupComparer(); radGridView1.MasterTemplate.GroupComparer = groupComparer; GroupDescriptor descriptor = new GroupDescriptor(); descriptor.GroupNames.Add("GroupName", ListSortDirection.Ascending); radGridView1.GroupDescriptors.Add(descriptor); } If you remove the Self-referencing hierarchy, you will notice that the GroupComparer is respected.
To reproduce: use the following code snippet and perform the steps illustrated on the attached gif file: http://www.telerik.com/help/winforms/gridview-filtering-excel-like-filtering.html public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add("Name", typeof(string)); DateTime date; for (int i = 0; i < 5; i++) { date = DateTime.Today.AddDays(i); dt.Rows.Add(i,date, "Item." + i ); date = date.AddHours(2); dt.Rows.Add(i,date ,"Item." + i + ".2" ); date = date.AddMonths(i); dt.Rows.Add(i,date, "Item." + i + ".2"); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableFiltering = true; this.radGridView1.ShowHeaderCellButtons = true; ((GridViewDateTimeColumn)this.radGridView1.Columns[1]).FilteringMode = GridViewTimeFilteringMode.Date; this.radGridView1.FilterPopupRequired += radGridView1_FilterPopupRequired; } private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e) { if (e.Column.Name == "Date") { e.FilterPopup = new RadListFilterPopup(e.Column, true); } } Workaround: RadListFilterPopup popup; private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e) { if (e.Column.Name == "Date") { if (popup == null) { popup = new RadListFilterPopup(e.Column, true); } e.FilterPopup = popup; } }
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: - Populate the grid with some double values. - Change the culture to Dutch(Belgian) - Export the grid Workaround: void spreadExporter_CellFormatting(object sender, Telerik.WinControls.UI.Export.SpreadExport.CellFormattingEventArgs e) { if (e.GridColumnIndex == 0 && e.GridCellInfo.Value != string.Empty) { CellValueFormat cvf = new CellValueFormat("0,00"); e.CellSelection.SetFormat(cvf); e.CellSelection.SetValue(((double)e.GridCellInfo.Value)); } }
One should be able to replace the exported file if such exists.
How to reproduce: just create a grid with a great number of rows e.g. 15000 and scroll down using the page down key Workaround: public partial class Form1 : Form { public Form1() { InitializeComponent(); BaseGridBehavior gridBehavior = radGridView1.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior()); DataTable dataTable = new DataTable(); dataTable.Columns.Add("Id", typeof(int)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("IsValid", typeof(bool)); for (int i = 0; i < 14000; i++) { dataTable.Rows.Add(i, "Name " + i, i % 2 == 0 ? true : false); } this.radGridView1.DataSource = dataTable; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; } } public class CustomGridDataRowBehavior : GridDataRowBehavior { protected override bool ProcessPageUpKey(KeyEventArgs keys) { GridTableElement tableElement = (GridTableElement)this.GridViewElement.CurrentView; int index = this.GridViewElement.CurrentRow.Index - tableElement.RowsPerPage + 1; if (index < 0) { index = 0; } GridViewRowInfo firstScrollableRow = this.GridControl.Rows[index]; this.GridViewElement.CurrentRow = firstScrollableRow; return true; } protected override bool ProcessPageDownKey(KeyEventArgs keys) { GridTableElement tableElement = (GridTableElement)this.GridViewElement.CurrentView; int index = this.GridViewElement.CurrentRow.Index + tableElement.RowsPerPage - 1; if (index > this.GridControl.Rows.Count - 1) { index = this.GridControl.Rows.Count - 1; } GridViewRowInfo lastScrollableRow = this.GridControl.Rows[index]; this.GridViewElement.CurrentRow = lastScrollableRow; return true; } }
To reproduce: - Add a column to the grid and try to set its IsPinned property to true.
To reproduce: public Form1() { InitializeComponent(); GridViewDecimalColumn idColumn = new GridViewDecimalColumn("ID"); radGridView1.MasterTemplate.Columns.Add(idColumn); GridViewDecimalColumn parentIdColumn = new GridViewDecimalColumn("ParentID"); radGridView1.MasterTemplate.Columns.Add(parentIdColumn); GridViewTextBoxColumn nameColumn = new GridViewTextBoxColumn("Name"); radGridView1.MasterTemplate.Columns.Add(nameColumn); GridViewTextBoxColumn addressColumn = new GridViewTextBoxColumn("Address"); radGridView1.MasterTemplate.Columns.Add(addressColumn); GridViewTextBoxColumn typeColumn = new GridViewTextBoxColumn("Type"); radGridView1.MasterTemplate.Columns.Add(typeColumn); radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID"); AddNewRow("1", null, "Project", "USA", "Project"); AddNewRow("2", "1", "Site 1", "New York", "Site"); AddNewRow("3", "2", "Bldg 1", "Road 1", "Building"); AddNewRow("4", "1", "Site 2", "New York", "Site"); AddNewRow("5", "4", "Bldg 2", "Road 2", "Building"); AddNewRow("20", "3", "Floor 1", "Road 20", "Floor"); AddNewRow("30", "3", "Floor 2", "Road 30", "Floor"); AddNewRow("40", "3", "Floor 3", "Road 40", "Floor"); } public void AddNewRow( params object[] values) { if (values.Length != radGridView1.Columns.Count) return; GridViewRowInfo newRow = radGridView1.Rows.AddNew(); newRow.Cells[0].Value = values[0]; newRow.Cells[1].Value = values[1]; newRow.Cells[2].Value = values[2]; newRow.Cells[3].Value = values[3]; newRow.Cells[4].Value = values[4]; } When you run the project you will notice that the last row is missing (AddNewRow("40", "3", "Floor 3", "Road 40", "Floor");). Please refer to the attached screenshots. Workaround: use the Rows.Add(params) method instead:
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(); } }
Version 2014.3.1202.40 scrolling worsened How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); DataTable dataTable = new DataTable(); dataTable.Columns.Add("Id", typeof(int)); dataTable.Columns.Add("Id2", typeof(int)); dataTable.Columns.Add("Id3", typeof(int)); dataTable.Columns.Add("Id4", typeof(int)); for (int i = 0; i < 10000; i++) { dataTable.Rows.Add(i, i + 10, i +20, i+30); } this.radGridView1.DataSource = dataTable; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.Load += Form1_Load; } private void Form1_Load(object sender, EventArgs e) { ExpressionFormattingObject idObj = new ExpressionFormattingObject("1", "Id % 2 = 0", false); idObj.CellBackColor = Color.SkyBlue; idObj.CellForeColor = Color.Red; this.radGridView1.Columns["Id"].ConditionalFormattingObjectList.Add(idObj); ExpressionFormattingObject idObj2 = new ExpressionFormattingObject("1", "Id2 % 2 = 0", false); idObj2.CellBackColor = Color.LightGray; idObj2.CellForeColor = Color.Red; this.radGridView1.Columns["Id2"].ConditionalFormattingObjectList.Add(idObj2); ExpressionFormattingObject idObj3 = new ExpressionFormattingObject("1", "Id3 % 2 = 0", false); idObj3.CellBackColor = Color.LightGreen; idObj3.CellForeColor = Color.Red; this.radGridView1.Columns["Id3"].ConditionalFormattingObjectList.Add(idObj3); ExpressionFormattingObject idObj4 = new ExpressionFormattingObject("1", "Id4 % 2 = 0", false); idObj4.CellBackColor = Color.LightYellow; idObj4.CellForeColor = Color.Red; this.radGridView1.Columns["Id4"].ConditionalFormattingObjectList.Add(idObj4); } } Workaround: Apply formatting on CellFormatting event
Workaround - hide the expander items if space is not enough: private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) { GridDataCellElement cell = e.CellElement as GridDataCellElement; if (cell != null && cell.SelfReferenceLayout != null) { foreach (RadElement element in cell.SelfReferenceLayout.StackLayoutElement.Children) { GridExpanderItem expanderItem = element as GridExpanderItem; if (expanderItem != null) { if (cell.ColumnInfo.Width < cell.SelfReferenceLayout.StackLayoutElement.Size.Width) { expanderItem.Opacity = 0; } else { expanderItem.Opacity = 1; } } } } }
To reproduce: this.radGridView1.MultiSelect = true; GroupDescriptor descriptor1 = new GroupDescriptor(); descriptor1.GroupNames.Add("ProductId", ListSortDirection.Ascending ); this.radGridView1.GroupDescriptors.Add(descriptor1); Please refer to the attached gif file.
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: 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.
Use the following code snippet and follow the illustrated steps on the attached gif file: private void Form1_Load(object sender, EventArgs e) { this.customersTableAdapter.Fill(this.nwindDataSet.Customers); this.radGridView1.DataSource = this.customersBindingSource; this.radGridView1.BestFitColumns(BestFitColumnMode.AllCells); ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition(); view.ColumnGroups.Add(new GridViewColumnGroup("Customer Contact")); view.ColumnGroups.Add(new GridViewColumnGroup("Details")); view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Address")); view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Contact")); view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow()); view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["CompanyName"]); view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactName"]); view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactTitle"]); view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow()); view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Address"]); view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["City"]); view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Country"]); view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow()); view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Phone"]); view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Fax"]); radGridView1.ViewDefinition = view; }