To reproduce: - Add GridViewComboBoxColumn to a grid. - Set the DisplayMemeber property like this: column1.DisplayMember = "AddInfo.Status";
To reproduce: Add a RadGridView to a form, dont dock it. Use the following code to add the rows, columns and the definition: this.Grid.Columns.Add("Old"); this.Grid.Columns.Add("New"); Start the application and you will see that you cannot scroll to the end, horizontally. Workaround: Use the following code on a button click or execute it in a timer a few millisecond after the form has loaded in order to update the scrollbar's maximum value accordingly: int width = 0; foreach (var col in this.Grid.Columns) { width += col.Width; } this.Grid.TableElement.HScrollBar.Maximum = width - this.Grid.TableElement.HScrollBar.SmallChange - this.Grid.TableElement.RowHeaderColumnWidth;
Steps to reproduce: 1. expand a parent row 2. remove the first child row (e.g. 'Jon Smith') by selecting the child row and press the button at the top 3. remove the second (last) child row (in this case 'Pete van Dijk') the same way Here is the code snippet: public partial class Form1 : Form { private List<Department> _departments; public Form1() { InitializeComponent(); SetGridParentColumns(); SetGridChildTemplate(); InitData(); grid.RowSourceNeeded += grid_RowSourceNeeded; } private void InitData() { _departments = new List<Department>(2); Department dep1 = new Department() { DepartmentId = 1, Name = "Accounting" }; Department dep2 = new Department() { DepartmentId = 2, Name = "Finance" }; Employee emp1 = new Employee() { DepartmentId = 1, EmployeeId = 1, FirsName = "John", LastName = "Smith" }; Employee emp2 = new Employee() { DepartmentId = 1, EmployeeId = 2, FirsName = "Pete", LastName = "van Dijk" }; Employee emp3 = new Employee() { DepartmentId = 2, EmployeeId = 3, FirsName = "Mark", LastName = "Smith" }; Employee emp4 = new Employee() { DepartmentId = 2, EmployeeId = 4, FirsName = "Jan", LastName = "Janssen" }; dep1.Employees = new List<Employee>() { emp1, emp2 }; dep2.Employees = new List<Employee>() { emp3, emp4 }; _departments.Add(dep1); _departments.Add(dep2); grid.DataSource = _departments; grid.AllowAddNewRow = false; grid.BestFitColumns(); } private void SetGridParentColumns() { grid.AutoGenerateColumns = false; grid.Columns.Add("DepartmentId", "DepartmentId", "DepartmentId"); grid.Columns.Add("Name", "Name", "Name"); } private void SetGridChildTemplate() { grid.Templates.Clear(); GridViewTemplate childTemplate = new GridViewTemplate(); childTemplate.Columns.Add("EmployeeId"); childTemplate.Columns.Add("DepartmentId"); childTemplate.Columns.Add("FirstName"); childTemplate.Columns.Add("LastName"); grid.Templates.Add(childTemplate); childTemplate.HierarchyDataProvider = new GridViewEventDataProvider(childTemplate); } private void grid_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e) { Department dep = e.ParentRow.DataBoundItem as Department; foreach (Employee employee in dep.Employees) { GridViewRowInfo gridRow = e.Template.Rows.NewRow(); gridRow.Cells["EmployeeId"].Value = employee.EmployeeId; gridRow.Cells["DepartmentId"].Value = employee.DepartmentId; gridRow.Cells["FirstName"].Value = employee.FirsName; gridRow.Cells["LastName"].Value = employee.LastName; e.SourceCollection.Add(gridRow); } e.Template.AllowAddNewRow = false; e.Template.BestFitColumns(); } private void btnRemoveChildRow_Click(object sender, EventArgs e) { GridViewRowInfo row = grid.SelectedRows[0]; if (row.ViewTemplate.Parent == null) return; //department (parent) row, so don't remove it int employeeId = Convert.ToInt32(row.Cells["EmployeeId"].Value); int departmentId = Convert.ToInt32(row.Cells["DepartmentId"].Value); Department dep = GetDepartment(departmentId); dep.RemoveEmployee(employeeId); row.ViewTemplate.Refresh(); } private Department GetDepartment(int departmentId) { foreach (Department dep in _departments) if (dep.DepartmentId == departmentId) return dep; return null; } } public class Department { public int DepartmentId { get; set; } public string Name { get; set; } public List<Employee> Employees { get; set; } public void RemoveEmployee(int employeeId) { Employee empToRemove = null; foreach (Employee emp in Employees) { if (emp.EmployeeId == employeeId) { empToRemove = emp; break; } } if (empToRemove != null) Employees.Remove(empToRemove); } } public class Employee { public int DepartmentId { get; set; } public int EmployeeId { get; set; } public string FirsName { get; set; } public string LastName { get; set; } } Workaround: use the ViewInfo.Refresh method instead of the ViewTemplate.Refresh method
1.Different naming of RadGridView templates (in the Smart tag - Relations section and in the Property Builder - Relations section) is confusing. 2.Column reordering via drag and drop in the same template. This action will change the object order of the grid. All changes are shown in the Preview section: I can select columns listed in the object tree, but cannot drag them up or down within a template. The only way I can reorder columns in the property builder appears to be by dragging them left or right in the preview pane. 3.Column moving via drag and drop from one template to another template. This action will change the object order of the grid. All changes are shown in the Preview section: I cannot move columns in the object tree from one template to another. 4.Template reordering via drag and drop. All changes are shown in the Preview section: drag and drop operation for templates in not allowed. 5.There is a right-click context menu for the object tree, with the following options: "Edit", "Expand / Collapse", "New", "Delete". Under no circumstances do the options "Edit" and "New" ever become enabled. 6.The preview pane displays a preview of the columns for the master template. When the child template is selected, the preview pane still shows a preview of the columns for the master template. As such, it is not possible to reorder columns for child templates in the preview pane. 7.When you set up the RadGridView hierarchy automatically at design time and open the Property Builder, all templates are visualized. It is possible to select/deselect columns from the different templates. It is possible to change columns names. However, when you press the OK button and close the Property Builder, try to reopen it. As a result you will notice that all columns from all child templates are selected and all columns contain the default names, no matter what changes were performed. Refer to the corresponding help article http://www.telerik.com/help/winforms/gridview-design-time-support-property-builder.html
To reproduce: -add hierarchical RadGriddView with one parent template and several child templates; -set TableElement.PageViewMode to PageViewMode.ExplorerBar; Selection for different templates is not performed correcltly. Workaround: use custom GridDataRowBehavior: BaseGridBehavior gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new RowSelectionGridBehavior()); public class RowSelectionGridBehavior : GridDataRowBehavior { protected override bool OnMouseDownLeft(MouseEventArgs e) { GridDataRowElement row = this.GetRowAtPoint(e.Location) as GridDataRowElement; if (row != null) { row.RowInfo.IsSelected = true; row.RowInfo.IsCurrent = true; return true; } return base.OnMouseDownLeft(e); } }
To reproduce: -add a RadGridView and use the following code: public Form1() { InitializeComponent(); GridViewComboBoxColumn comboColumn = new GridViewComboBoxColumn("ComboBox column"); comboColumn.DataSource = new List<string>() { "first", "second", "third" }; radGridView1.Columns.Add(comboColumn); radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized; } private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDropDownListEditor dropDownEditor = radGridView1.ActiveEditor as RadDropDownListEditor; RadDropDownListEditorElement dropDownEditorElement = dropDownEditor.EditorElement as RadDropDownListEditorElement; dropDownEditorElement.SelectedIndex = 0; } If you try to add a new row in the grid, the first item in the RadDropDownListEditor is selected. If you do not make any selection changes and press Enter key, the new row will not be added. Workaround: use the DefaultValuesNeeded event for initializing RadDropDownListEditorElement's selectin
To reproduce: 1. Add RadGridView with 2 columns 2. Sort first column. Then sort second column. 3. Break in the SortChanged event handler method 4. e.NewItems[0].PropertyName is 'column1' and e.OldItems[0].PropertyName is 'column2', the values are swapped
To reproduce: -add a RadGridView and bind it to Northwind.Customers datatable. -try to edit a random row and change its CustomerID cell to an already existing one. Workaround: use custom GridViewDataRowInfo: public class CustomRowInfo : GridViewDataRowInfo { public CustomRowInfo(GridViewInfo viewInfo) : base(viewInfo) { } protected override bool OnEndEdit() { IEditableObject dataItem = this.DataBoundItem as IEditableObject; if (dataItem != null) { try { dataItem.EndEdit(); } catch (Exception ex) { this.ViewTemplate.SetError(new GridViewCellCancelEventArgs(null,null, null), ex); } } return base.OnEndEdit(); } }
Workaround: public Form1() { InitializeComponent(); radGridView1.CreateCell += radGridView1_CreateCell; } private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) { if (e.CellType == typeof(GridDataCellElement)) { e.CellElement = new CustomDataCell(e.Column,e.Row); } } public class CustomDataCell : GridDataCellElement { public CustomDataCell(GridViewColumn column, GridRowElement row) : base(column, row) { } protected override Type ThemeEffectiveType { get { return typeof(GridDataCellElement); } } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left && this.AllowRowReorder && this.ViewTemplate.AllowRowReorder && Cursor.Current != Cursors.SizeNS) { base.OnMouseDown(e); } } }
To reproduce: - add RadGridView and use the following code: public Form1() { InitializeComponent(); DataTable source = new DataTable(); string colName = string.Empty; for (var i = 0; i < 10; i++) { colName = "col" + i.ToString(); this.Grid.Columns.Add(new GridViewTextBoxColumn(colName)); source.Columns.Add(new DataColumn(colName)); } this.Grid.DataSource = source; } - Run the project, click over the grid and press PageUp key. As a result NullReferenceException is thrown. Workaround: use custom BaseGridBehavior: this.radGridView1.GridBehavior = new CustomGridBehavior(); public class CustomGridBehavior : BaseGridBehavior { protected override bool ProcessPageUpKey(KeyEventArgs keys) { GridTableElement tableElement = (GridTableElement)this.GridViewElement.CurrentView; GridViewRowInfo firstScrollableRow = GetFirstScrollableRow(tableElement, true); RadScrollBarElement scrollBar = tableElement.VScrollBar; if (this.GridViewElement.CurrentRow == firstScrollableRow && firstScrollableRow!=null) { int height = (int)tableElement.RowScroller.ElementProvider.GetElementSize(firstScrollableRow).Height; int newValue = scrollBar.Value - scrollBar.LargeChange + height + tableElement.RowScroller.ScrollOffset; scrollBar.Value = Math.Max(newValue, scrollBar.Minimum); tableElement.UpdateLayout(); firstScrollableRow = GetFirstScrollableRow(tableElement, false); } this.GridViewElement.Navigator.SelectRow(firstScrollableRow); this.NavigateToPage(firstScrollableRow, keys.KeyData); return true; } }
To reproduce: - add a RadGridView with one column - GridViewMultiComboBoxColumn; - set DataSource property of the column; - subscribe to the CellValidating and use the following code: private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e) { e.Cancel = true; } Run the application and select a value from the GridViewMultiComboBoxColumn. When pressing Enter key, InvalidCastException is thrown. Workaround: radGridView1.EditorManager.CloseEditorWhenValidationFails = true;
To reproduce: Add a TabControl and two tabs. In the second tab add a RadGridView and in the Load event of the form set the SplitMode property of the grid. You will notice that it will not have effect until grouping or other similar action has been performed. Workaround: private void Form1_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("column1"); dt.Columns.Add("column2"); RadGridView1.DataSource = dt; this.RadGridView1.VisibleChanged += Visible_Changed; } private void Visible_Changed(object sender, EventArgs e) { if (this.RadGridView1.Visible & !this.RadGridView1.SplitMode.Equals(Telerik.WinControls.UI.RadGridViewSplitMode.Horizontal)) { RadGridView1.SplitMode = Telerik.WinControls.UI.RadGridViewSplitMode.Horizontal; } }
To reproduce: Add a RadGridView and use the following code to populate it: for (int i = 0; i < 15; i++) { this.grid.Columns.Add(string.Format("Column {0}", i)); } for (int i = 0; i < this.grid.Columns.Count * 15; i++) { this.grid.Rows.AddNew(); }t Set the theme to TelerikMetroTouch. Scroll somewhere below the middle leave the scrollbar and leave the grid with the mouse. You will notice that the value of the scrollbar will change. Workaround: Subscribe to the RadPropertyChanging event of the TableElement: RadGridView1.TableElement.RadPropertyChanging += Property_Changing; void TableElement_RadPropertyChanging(object sender, RadPropertyChangingEventArgs args) { args.Cancel = args.Property == GridTableElement.RowHeightProperty || args.Property == GridTableElement.TableHeaderHeightProperty || args.Property == GridTableElement.GroupHeaderHeightProperty || args.Property == GridTableElement.FilterRowHeightProperty; }
Extend the cell elements with a button(s) (via decorator for example) which will be visible without putting the grid in edit mode. The buttons should not be visible by default and their visibility will be controlled via property of the column. These buttons can be RadButtonElements which will not hurt the performance. Their purpose will be to inform the end user that some cell is a combo or a date time cell without having to open its editor in advance. When the button is clicked, the corresponding action should be executed e.g. for combo cell, open the editor and show the popup; for spin cell open the editor and perform the click of the desired button. Same goes for the rest of the editors - mccb, color, browse, date time, etc.
There should be a way to fix the width of certain columns. Their width should remain the same while resizing the grid.
To reproduce: 1. Add RadGridView with 3 columns and add summary row 2. When is fired the ViewCellFormatting event, set the Text property of GridSummaryCellElement 3. Run project and text is not visible. void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { GridSummaryCellElement summaryCell = e.CellElement as GridSummaryCellElement; if (summaryCell != null) { if (summaryCell.ColumnInfo.FieldName == "ProductID") { summaryCell.Text = "Total"; } } } Workaround: Set FormatString property instead Text property void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { GridSummaryCellElement summaryCell = e.CellElement as GridSummaryCellElement; if (summaryCell != null) { if (summaryCell.ColumnInfo.FieldName == "ProductID") { summaryCell.FormatString = "Total"; } } }
To reproduce: -add a RadGridView and a RadButton; Use the following code: public Form1() { InitializeComponent(); List<Item> list = new List<Item>() { new Item(1, "<AUD#F-DC>") }; radGridView1.DataSource = list; } public class Item { public int ID { get; set; } public string Title { get; set; } public Item(int iD, string title) { this.ID = iD; this.Title = title; } } private void Form1_Load(object sender, EventArgs e) { this.employeesTableAdapter.Fill(this.nwindDataSet.Employees); } private void radButton1_Click(object sender, EventArgs e) { ExportToPDF pdfExporter = new ExportToPDF(this.radGridView1); pdfExporter.PdfExportSettings.Title = "My PDF Title"; pdfExporter.PdfExportSettings.PageWidth = 297; pdfExporter.PdfExportSettings.PageHeight = 210; pdfExporter.PageTitle = "temp"; pdfExporter.FitToPageWidth = true; pdfExporter.SummariesExportOption = SummariesOption.ExportAll; pdfExporter.ExportVisualSettings = true; try { pdfExporter.RunExport(@"..\..\..\pdfExport.pdf"); } catch (IOException ex) { RadMessageBox.Show(this, ex.Message, "I/O Error", MessageBoxButtons.OK, RadMessageIcon.Error); } } Workaround: pdfExporter.HTMLCellFormatting += pdfExporter_HTMLCellFormatting; private void pdfExporter_HTMLCellFormatting(object sender, HTMLCellFormattingEventArgs e) { string val = e.HTMLCellElement.Value; e.HTMLCellElement.Value = val.Replace("<", "<").Replace(">", ">"); }
To reproduce: -add a RadGridView and a RadButton; use the following code: public Form1() { InitializeComponent(); //Create a child template GridViewTemplate childTemplate = new GridViewTemplate(); childTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.Templates.Add(childTemplate); GridViewRelation relation = new GridViewRelation(); relation.ChildTemplate = childTemplate; relation.ParentTemplate = this.radGridView1.MasterTemplate; relation.ChildColumnNames.Add("B1"); relation.ParentColumnNames.Add("A1"); this.radGridView1.Relations.Add(relation); } private DataTable dtParent; private DataTable dtChild; private void Form1_Load(object sender, EventArgs e) { //Add data dtParent = new DataTable(); dtParent.Columns.AddRange(new DataColumn[] { new DataColumn("A1") }); dtChild = new DataTable(); dtChild.Columns.AddRange(new DataColumn[] { new DataColumn("B1"), new DataColumn("B2") }); DataRow dr = dtParent.NewRow(); dr["A1"] = "0"; dtParent.Rows.Add(dr); for (int i = 0; i < 40; i++) { DataRow drChild = dtChild.NewRow(); drChild["B1"] = "0"; drChild["B2"] = ""; dtChild.Rows.Add(drChild); } this.radGridView1.MasterTemplate.DataSource = dtParent; this.radGridView1.Templates[0].DataSource = dtChild; } private void radButton1_Click(object sender, EventArgs e) { DataRow drNew = this.dtChild.NewRow(); drNew["B1"] = "0"; drNew["B2"] = "New"; this.dtChild.Rows.Add(drNew); } If you expand the first parent row and scroll down to the last child row, clicking over the button does not refresh the vertical scroll-bar correctly. The new row shows only half. You can not scroll to the end. Workaround: refresh the vertical scroll-bar manually: private void radButton1_Click(object sender, EventArgs e) { DataRow drNew = this.dtChild.NewRow(); drNew["B1"] = "0"; drNew["B2"] = "New"; this.dtChild.Rows.Add(drNew); int val = radGridView1.TableElement.VScrollBar.Value; foreach (GridViewRowInfo row in radGridView1.Rows) { if (row.IsExpanded) { val = radGridView1.TableElement.VScrollBar.Value; row.IsExpanded = false; row.IsExpanded = true; radGridView1.TableElement.VScrollBar.Value = val; } } }
To reproduce: Add a RadGridView and bind it to a DataTable. Subscribe to the TableElement's vertical scroll's ValueChanged event and add new data when the value reaches the maximum: private void RequestData(int startFrom, int count) { for (int i = 0; i < count; i++) { DataRow row = dt.NewRow(); row["ID"] = startFrom + i; dt.Rows.Add(row); } } private void VScrollBar_ValueChanged(object sender, EventArgs e) { if (dgwData.TableElement.VScrollBar.Value + dgwData.TableElement.VScrollBar.LargeChange >= dgwData.TableElement.VScrollBar.Maximum) { int maxVScrollBarBefore = dgwData.TableElement.VScrollBar.Maximum; dgwData.SelectionChanged -= dgwData_SelectionChanged; dgwData.TableElement.VScrollBar.ValueChanged -= VScrollBar_ValueChanged; RequestData(dt.Rows.Count, rowsToCharge); dgwData.SelectionChanged += dgwData_SelectionChanged; dgwData.TableElement.VScrollBar.ValueChanged += VScrollBar_ValueChanged; } } You will notice that when you use the mousewheel the scrollbar is being updated, but when you use the arrows it is not. Workaround: Invoke the UpdateScrollRange method of the TableElement's RowScroller after adding the new data: dgwData.TableElement.RowScroller.UpdateScrollRange();