To reproduce: create a form with a button on it where on its Click event you show another form with the following code snippet: public class Dummy { public int ID { get; set; } public string Description { get; set; } } public Form1() { InitializeComponent(); this.radGridView1.FilterChanged += radGridView1_FilterChanged; if (File.Exists(@"..\..\..\layout.xml")) { this.radGridView1.LoadLayout(@"..\..\..\layout.xml"); } else { radGridView1.Columns.Add(new GridViewTextBoxColumn { HeaderText = "Id ", FieldName = "ID" }); radGridView1.Columns.Add(new GridViewTextBoxColumn { HeaderText = "Description", FieldName = "DESCRIPTION" }); } radGridView1.EnableFiltering = true; radGridView1.MasterTemplate.ShowHeaderCellButtons = true; radGridView1.MasterTemplate.ShowFilteringRow = true; var items = new List<Dummy>(); for (int i = 0; i < 20; i++) { var dummy = new Dummy { ID = i, Description = string.Format("Description_{0}", i) }; items.Add(dummy); } radGridView1.AutoGenerateColumns = false; radGridView1.DataSource = items; } private void radGridView1_FilterChanged(object sender, GridViewCollectionChangedEventArgs e) { this.radGridView1.SaveLayout(@"..\..\..\layout.xml"); } Please refer to the attached gif file illustrating the steps.
To reproduce: 1. Use the following code: private void Form1_Load(object sender, EventArgs e) { this.customersTableAdapter.Fill(this.nwindDataSet.Customers); this.radGridView1.DataSource = customersBindingSource; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.CellEndEdit += radGridView1_CellEndEdit; this.radGridView1.AutoSizeRows = true; SortDescriptor descriptor = new SortDescriptor(); descriptor.PropertyName = "Country"; descriptor.Direction = ListSortDirection.Ascending; this.radGridView1.MasterTemplate.SortDescriptors.Add(descriptor); } void radGridView1_CellEndEdit(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { int selectedRowIndex = this.radGridView1.ChildRows.IndexOf(this.radGridView1.CurrentRow); this.radGridView1.TableElement.ScrollToRow(selectedRowIndex); } 2. Modify cell value in the sorted column. After the editor value is confirmed by pressing Enter, you scroll to the current column. However, you do not observe the expected behavior. Workaround: set the AutoSizeRows property to false.
To reproduce: radGridView1.TableElement.ColumnScroller.ScrollMode = ItemScrollerScrollModes.Discrete; Workaround: radGridView1.TableElement.HScrollBar.MouseUp += RadGridView1_HScrollBarMouseUp; private void RadGridView1_HScrollBarMouseUp(object sender, MouseEventArgs e) { int ixCol = GetLeftCol(radGridView1); Debug.WriteLine( "Index = "+ ixCol); if (ixCol > -1) { radGridView1.TableElement.ScrollToColumn(ixCol); radGridView1.Rows[0].Cells[ixCol].EnsureVisible(); } } private int currentLeftColumnIndex = 0; private int lastScrollPos = 0; public int GetLeftCol(RadGridView grd) { try { if (!grd.Columns.Any()) return -1; if (!grd.TableElement.VisualRows.Any()) return -1; if (grd.TableElement.ColumnScroller.Scrollbar.Value == 0) return -1; GridRowElement firstVisualRow = grd.TableElement.VisualRows.Where(r => r is Telerik.WinControls.UI.GridDataRowElement).First(); GridCellElement firstVisualCell = firstVisualRow.VisualCells.Where(c => c is Telerik.WinControls.UI.GridDataCellElement).First(); GridCellElement lastVisualCell = firstVisualRow.VisualCells.Where(c => c is Telerik.WinControls.UI.GridDataCellElement).Last(); if (grd.TableElement.ColumnScroller.Scrollbar.Value > lastScrollPos) { //"Scrolling Right" if (lastVisualCell.ColumnIndex == grd.Columns.Last().Index) { lastScrollPos = grd.TableElement.ColumnScroller.Scrollbar.Value; return -1; } if (currentLeftColumnIndex == firstVisualCell.ColumnIndex) { currentLeftColumnIndex += 1; } else { currentLeftColumnIndex = firstVisualCell.ColumnIndex < grd.Columns.Count ? firstVisualCell.ColumnIndex : grd.Columns.Count - 1; } lastScrollPos = grd.TableElement.ColumnScroller.Scrollbar.Value + 1; } else { currentLeftColumnIndex = firstVisualCell.ColumnIndex; lastScrollPos = grd.TableElement.ColumnScroller.Scrollbar.Value - 1; } return currentLeftColumnIndex; } catch (Exception ex) { return -1; } }
The columns are not re sized proportionally when the RadGridView is re sized in auto-size column mode fill.
To reproduce: - Crete a self-reference hiearchy and show the grid lines. - Start the application expand some rows scroll to the bottom and then scroll to the right. - The issue is easily reproducible with the example from the documentation. Workaround: class MyDataCellElement : GridDataCellElement { public MyDataCellElement(GridViewColumn col, GridRowElement row) : base(col, row) { } protected override SizeF ArrangeOverride(SizeF finalSize) { SelfReferenceCellLayout selfReferenceLayout = this.SelfReferenceLayout; if (selfReferenceLayout != null) { GridDataRowElement dataRowElement = this.RowElement as GridDataRowElement; if (dataRowElement != null && this.ColumnInfo.OwnerTemplate != null) { dataRowElement.SelfReferenceLayout.StackLayoutElement.Visibility = ElementVisibility.Visible; } } else { GridDataRowElement dataRowElement = this.RowElement as GridDataRowElement; if (dataRowElement != null && this.ColumnInfo.OwnerTemplate != null) { dataRowElement.SelfReferenceLayout.StackLayoutElement.Visibility = ElementVisibility.Collapsed; } } return base.ArrangeOverride(finalSize); } protected override Type ThemeEffectiveType { get { return typeof(GridDataCellElement); } } }
To reproduce: Open the examples and navigate to GridView -> RightToLeft and toggle on RightToLeft. You will see that the GridGroupHeaderRowElements will have its text LeftToRight. Workaround: Use ViewCellFormatting: private void Grid_ViewCellFormatting15(object sender, CellFormattingEventArgs e) { if (e.CellElement.RowElement is GridGroupHeaderRowElement && e.CellElement.RowElement.Children.Any() && e.CellElement.RowElement.Children.Last() is GridGroupContentCellElement) { (e.CellElement.RowElement.Children.Last() as GridGroupContentCellElement).TextAlignment = System.Drawing.ContentAlignment.MiddleRight; } }
Currently, in order to display the "Deleter Row" context menu item, you should set both properties, AllowEditRow and AllowDeleteRow, to true. However, if you use the Delete key, it will remove the row if only the AllowDeleteRow property is set to true.
To reproduce: - Remove the new row from the grid. - Start the application and delete all rows. - When the last row is deleted the SelectionChanged does not fire. Workaround: - Use the UserDeletedRow event instead.
To reproduce: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Col@", typeof(string)); dt.Rows.Add("Unit"); this.radGridView1.DataSource = dt; this.radGridView1.EnableFiltering = true; this.radGridView1.BestFitColumns(); } Workaround: modify the Name of each column in order to remove the "@" symbol: foreach (GridViewColumn c in this.radGridView1.Columns) { c.Name = c.Name.Replace("@", ""); }
If you select a row and click with the right mouse button on the header row column, the context menu with Cut, Copy, Paste is shown. If you click the Cut item, it will cut only a single cell. However, if you Copy , the entire row will be copied. Workaround: public class CustomGrid : RadGridView { protected override RadGridViewElement CreateGridViewElement( { return new CustomRadGridViewElement(); } public override string ThemeClassName { get { return typeof(RadGridView).FullName; } } } public class CustomRadGridViewElement : RadGridViewElement { protected override MasterGridViewTemplate CreateTemplate() { return new CustomMasterGridViewTemplate(); } protected override Type ThemeEffectiveType { get { return typeof(RadGridViewElement); } } } public class CustomMasterGridViewTemplate : MasterGridViewTempla { public override void Cut() { this.BeginRowCopy(); this.Copy(); this.EndRowCopy(); foreach (GridViewRowInfo row in this.SelectedRows) { foreach (GridViewCellInfo cell in row.Cells) { cell.Value = null; } } } }
To reproduce: 1.Add a grid and populate it with data. 2.Apply a theme to the entire application, e.g. TelerikMetro 3.Activate the grid editor. 4.Change the theme to VisualStudio2012Dark or HigthContrastBlack. 5.Activate the grid editor again. You will notice that editor's back color remains white and you are not able to read the text. Note: if you apply initially VisualStudio2012Dark theme, editor's back color is correct. Please refer to the attached gif file, illustrating this incorrect style. Workaround: private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { BaseGridEditor gridEditor = e.ActiveEditor as BaseGridEditor; if (gridEditor != null) { RadTextBoxElement el = gridEditor.OwnerElement.FindDescendant<RadTextBoxElement>(); if (el != null) { if (ThemeResolutionService.ApplicationThemeName == "VisualStudio2012Dark") { el.BackColor = Color.Black; } } } }
To reproduce: use the following code snippet and click the button twice. private DataTable GetTable01() { DataTable table = new DataTable(); table.Columns.Add("Dosage", typeof(int)); table.Columns.Add("Drug", typeof(string)); table.Columns.Add("Patient", typeof(string)); table.Columns.Add("Date", typeof(DateTime)); // Here we add five DataRows. table.Rows.Add(25, "Indocin", "David", DateTime.Now); table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now); table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now); table.Rows.Add(21, "Combivent", "Janet", DateTime.Now); table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now); return table; } private void button1_Click_1(object sender, EventArgs e) { DataTable table01 = GetTable01(); radGridView1.Rows.Clear(); radGridView1.DataSource = table01; } WORKAROUND I: this.radGridView1.DataError += radGridView1_DataError; private void radGridView1_DataError(object sender, GridViewDataErrorEventArgs e) { if (e.Exception is ArgumentException && e.Exception.Message == "Cannot clear this list.") { this.radGridView1.BeginUpdate(); while (this.radGridView1.Rows.Count > 0) { this.radGridView1.Rows.RemoveAt(0); } this.radGridView1.EndUpdate(); } } WORKAROUND II: while (this.radGridView1.Rows.Count > 0) { this.radGridView1.Rows.RemoveAt(this.radGridView1.Rows.Count - 1); }
To reproduce: public Form1() { InitializeComponent(); this.Text = Telerik.WinControls.VersionNumber.MarketingVersion + " " + Telerik.WinControls.VersionNumber.Number; this.radGridView1.Dock = DockStyle.Fill; string[] coffeeDrinks = { "Americano", "Cafe Crema", "Caffe Latte", "Caffe macchiato", "Coffee milk", "Cafe mocha", "Irish coffee", }; DataTable tableDrinks = new DataTable(); tableDrinks.Columns.Add("DrinkID", typeof(int)); tableDrinks.Columns.Add("Drink", typeof(string)); tableDrinks.Columns.Add("State", typeof(bool)); for (int i = 0; i < coffeeDrinks.Length; i++) { if (i % 2 == 0) { tableDrinks.Rows.Add(i, coffeeDrinks[i], true); } else { tableDrinks.Rows.Add(i, coffeeDrinks[i], false); } } this.radGridView1.DataSource = tableDrinks; GroupDescriptor descriptor = new GroupDescriptor(); descriptor.GroupNames.Add("State", ListSortDirection.Ascending); this.radGridView1.GroupDescriptors.Add(descriptor); this.radGridView1.MasterTemplate.ExpandAllGroups(); this.radGridView1.TableElement.GroupIndent = 1; } When set the GroupIndent property to 1, the space should be 1 pixel. Currently is bigger than 1 pixel (see attached image). And when users wants to hide the indent column, can not set the GroupIndent property to 0. Workaround: this.radGridView1.TableElement.GroupIndent = 1; foreach (GridViewColumn col in this.radGridView1.TableElement.ViewElement.RowLayout.RenderColumns) { if (col is GridViewIndentColumn) { col.MinWidth = 0; break; } }
To reproduce: change the value for a GridCheckBoxCellElement. The editor is not active. However, if you click again over the current cell, the editor will be activated. Workaround: use a custom row behavior to close the editor: //register the custom row behavior BaseGridBehavior gridBehavior = sourceRadGridView.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior()); public class CustomGridDataRowBehavior : GridDataRowBehavior { public override bool OnMouseUp(MouseEventArgs e) { bool result = base.OnMouseUp(e); if (this.MasterTemplate.CurrentColumn is GridViewCheckBoxColumn ) { this.GridViewElement.EndEdit(); } return result; } }
To reproduce: DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Rows.Add(1, new string('G', 32001)); this.radGridView1.DataSource = dt; this.radGridView1.PrintPreview(); Workaround: this.radGridView1.PrintCellFormatting+=radGridView1_PrintCellFormatting; private void radGridView1_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e) { e.PrintCell.Text = e.PrintCell.Text.Substring(0,Math.Min(e.PrintCell.Text.Length, 32000)); }
To reproduce: public Form1() { InitializeComponent(); this.radGridView1.CellFormatting+=radGridView1_CellFormatting; DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name",typeof(string)); for (int i = 0; i < 100; i++) { dt.Rows.Add(i,"Item"+i); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) { e.Row.Height = 40; } private void radButton1_Click(object sender, EventArgs e) { this.radGridView1.TableElement.ScrollToRow(this.radGridView1.Rows.Count - 1); } Workaround: instead of using the CellFormatting event to set the Row.Height, you can set the TableElement.RowHeight property.
To reproduce: use the following code snippet and refer to the attached sample gif file. When you enter edit mode for the first time, the editor is empty. Each next entering edit mode displays the respective text in the editor, although it is cut off. public Form1() { InitializeComponent(); radGridView1.Font = new Font("Segoe UI", 18.0f); radGridView1.CellEditorInitialized += pgGrid_CellEditorInitialized; AddColumns(); radGridView1.DataSource = BuildDummyTable(); radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; } private void pgGrid_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadTextBoxEditor editor = e.ActiveEditor as RadTextBoxEditor; if (editor != null) { ((RadTextBoxEditorElement)editor.EditorElement).TextBoxItem.Multiline = true; ((RadTextBoxEditorElement)editor.EditorElement).Padding = new Padding(0); } } private void AddColumns() { GridViewTextBoxColumn colA = new GridViewTextBoxColumn("colA"); radGridView1.Columns.Add(colA); GridViewTextBoxColumn colB = new GridViewTextBoxColumn("colB"); radGridView1.Columns.Add(colB); GridViewTextBoxColumn colC = new GridViewTextBoxColumn("colC"); radGridView1.Columns.Add(colC); GridViewTextBoxColumn colD = new GridViewTextBoxColumn("colD"); radGridView1.Columns.Add(colD); } private DataTable BuildDummyTable() { DataTable table = new DataTable(); table.Columns.Add("colA"); table.Columns.Add("colB"); table.Columns.Add("colC"); table.Columns.Add("colD"); table.Rows.Add("value 1A", "value 1B", "value 1C", "value 1D"); table.Rows.Add("value 2A", "value 2B", "value 2C", "value 2D"); table.Rows.Add("value 3A", "value 3B", "value 3C", "value 3D"); return table; }
Workaround: public Form1() { InitializeComponent(); this.radGridView1.CreateCell += radGridView1_CreateCell; GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn("CheckBoxColumn"); checkBoxColumn.EnableHeaderCheckBox = false; checkBoxColumn.ThreeState = true; checkBoxColumn.EditMode = EditMode.OnValueChange; radGridView1.MasterTemplate.Columns.Add(checkBoxColumn); radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < 20; i++) { this.radGridView1.Rows.Add(false); } } private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) { if (e.CellType == typeof(GridCheckBoxHeaderCellElement)) { CustomGridCheckBoxHeaderCellElement headerCell = new CustomGridCheckBoxHeaderCellElement(e.Column, e.Row); e.CellElement = headerCell; } } public class CustomGridCheckBoxHeaderCellElement : GridHeaderCellElement { public CustomGridCheckBoxHeaderCellElement(GridViewColumn column, GridRowElement row) : base(column, row) { } protected override Type ThemeEffectiveType { get { return typeof(GridHeaderCellElement); } } RadCheckBoxElement cb = new RadCheckBoxElement(); protected override void CreateChildElements() { base.CreateChildElements(); this.Children.Add(cb); cb.IsThreeState = true; cb.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Off; cb.ToggleStateChanged += CheckBox_ToggleStateChanged; } bool boolValue = false; public override void SetContent() { base.SetContent(); if (!flag) { bool atLeastOneTrue = false; bool atLeastOneFalse = false; foreach (GridViewRowInfo r in this.GridViewElement.Template.Rows) { if (r.Cells[0].Value != null) { if (atLeastOneTrue && atLeastOneFalse) { break; } boolValue = (bool)r.Cells[0].Value; if (boolValue) { atLeastOneTrue = true; } else { atLeastOneFalse = true; } } else { atLeastOneFalse = true; } } if (atLeastOneFalse && atLeastOneTrue) { cb.ToggleStateChanged -= CheckBox_ToggleStateChanged; cb.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Indeterminate; cb.ToggleStateChanged += CheckBox_ToggleStateChanged; } else if (atLeastOneFalse == true) { cb.ToggleStateChanged -= CheckBox_ToggleStateChanged; cb.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Off; cb.ToggleStateChanged += CheckBox_ToggleStateChanged; } else if (atLeastOneTrue == true) { cb.ToggleStateChanged -= CheckBox_ToggleStateChanged; cb.ToggleState = Telerik.WinControls.Enumerations.ToggleState.On; cb.ToggleStateChanged += CheckBox_ToggleStateChanged; } } } bool flag = false; private void CheckBox_ToggleStateChanged(object sender, StateChangedEventArgs args) { cb.ToggleStateChanged -= CheckBox_ToggleStateChanged; flag = true; if (args.ToggleState == Telerik.WinControls.Enumerations.ToggleState.Indeterminate) { cb.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Off; } ToggleStateForChildRows(args.ToggleState, this.GridControl); flag = false; cb.ToggleStateChanged += CheckBox_ToggleStateChanged; } private void ToggleStateForChildRows(Telerik.WinControls.Enumerations.ToggleState toggleState, RadGridView radGridView) { foreach (GridViewRowInfo r in radGridView.Rows) { r.Cells[0].Value = toggleState == Telerik.WinControls.Enumerations.ToggleState.On; } } }
Note: it is reproducible when using ColumnGroupsViewDefinition too. Workaround: unpin all pinned columns before printing and restore their state after printing: