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:
To reproduce: public RadForm1() { InitializeComponent(); Controls.Add(new RadGridView { Dock = DockStyle.Fill, ShowHeaderCellButtons = true, ReadOnly = true, AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill, EnableFiltering = true, DataSource = Enumerable.Range(0, 24000) //Increase this number when you can't reproduce this issue .Select(x => new { Name = string.Format("Item {0}", x) }), }); } Workaround: class MyListFillter : RadListFilterPopup { public MyListFillter(GridViewDataColumn column, bool groupDateValues) : base(column, groupDateValues) { } protected override void OnButtonOkClick(EventArgs e) { FilterOperator filterOperator = FilterOperator.IsEqualTo; var listFilterElement = typeof(RadListFilterPopup).GetField("listFilterElement", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this) as FilterMenuTreeElement; switch (listFilterElement.SelectedMode) { case ListFilterSelectedMode.All: filterOperator = FilterOperator.None; break; case ListFilterSelectedMode.Null: filterOperator = FilterOperator.IsNull; break; case ListFilterSelectedMode.NotNull: filterOperator = FilterOperator.IsNotNull; break; } if (filterOperator != FilterOperator.IsEqualTo) { SetFilterOperator(filterOperator); this.ClosePopup(RadPopupCloseReason.CloseCalled); } else { CompositeFilterDescriptor compositeFilterDescriptor = new CompositeFilterDescriptor(); compositeFilterDescriptor.PropertyName = base.DataColumn.Name; compositeFilterDescriptor.LogicalOperator = FilterLogicalOperator.Or; if (listFilterElement.SelectedValues.Count > this.GetDistinctValuesTable().Count / 2) { foreach (DictionaryEntry entry in this.GetDistinctValuesTable()) { if (!listFilterElement.SelectedValues.Contains(entry.Key)) { foreach (object value in (ArrayList)entry.Value) { FilterDescriptor descriptor; if (base.DataColumn is GridViewDateTimeColumn || base.DataColumn.DataType == typeof(DateTime) || base.DataColumn.DataType == typeof(DateTime?)) { descriptor = new DateFilterDescriptor(base.DataColumn.Name, FilterOperator.IsNotEqualTo, (DateTime?)value, false); } else { descriptor = new FilterDescriptor(base.DataColumn.Name, FilterOperator.IsNotEqualTo, value); } compositeFilterDescriptor.FilterDescriptors.Add(descriptor); } } } } else { foreach (DictionaryEntry entry in listFilterElement.SelectedValues) { foreach (object value in (ArrayList)entry.Value) { FilterDescriptor descriptor; if (base.DataColumn is GridViewDateTimeColumn || base.DataColumn.DataType == typeof(DateTime) || base.DataColumn.DataType == typeof(DateTime?)) { descriptor = new DateFilterDescriptor(base.DataColumn.Name, FilterOperator.IsEqualTo, (DateTime?)value, false); } else { descriptor = new FilterDescriptor(base.DataColumn.Name, FilterOperator.IsEqualTo, value); } compositeFilterDescriptor.FilterDescriptors.Add(descriptor); } } } base.FilterDescriptor = compositeFilterDescriptor; OnFilterConfirmed(); } } }
To reproduce: - Bind the grid to a data source and set its RightToLeftProperty to true. Note: use Visual Studio 2008 under Windows XP with .NET 2.0 Workaround: Private Sub RadGridView1_ViewCellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) If RadGridView1.RightToLeft = Windows.Forms.RightToLeft.Yes Then e.CellElement.TextAlignment = ContentAlignment.MiddleLeft End If End Sub
To reproduce: - Add grid with a DateTime column with default value "5/1/2014"; - Start the app and press the following keys one after another: 5/1/ - You will notice that the "1" is not replaced. Please note that the similar behavior occur when the year is entered (it does not match the default one). Workaround handle the key press for such cases manually: void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDateTimeEditor ed = e.ActiveEditor as RadDateTimeEditor; RadDateTimeEditorElement el = ed.EditorElement as RadDateTimeEditorElement; el.KeyPress += el_KeyPress; } private void el_KeyPress(object sender, KeyPressEventArgs e) { RadDateTimeEditorElement el = (RadDateTimeEditorElement)sender; int day = el.Value.Value.Day; int key = -1; int.TryParse(e.KeyChar.ToString(), key); RadMaskedEditBoxElement element = el.TextBoxElement.TextBoxItem.Parent as RadMaskedEditBoxElement; MaskDateTimeProvider provider = element.Provider as MaskDateTimeProvider; if (provider.SelectedItemIndex == 2) { if (key > 0 & key <= 9) { if (el.TextBoxElement.TextBoxItem.SelectionLength != 0) { if (!booKeying) { dynamic NewValue = new DateTime(el.Value.Value.Year, el.Value.Value.Month, key); el.Value = NewValue; e.Handled = true; booKeying = true; } } } } }
Workaround: check for the theme and set a minimum size to the text box item 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.TextBoxItem.MinSize = new Size(0, 20); el.TextBoxItem.TextBoxControl.MinimumSize = new Size(0, 20); } } } }
To reproduce: protected override void OnLoad(EventArgs e) { this.radGridView1.AllowAddNewRow = false; this.radGridView1.TableElement.RowHeight = 40; this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewTextBoxColumn id = new GridViewTextBoxColumn("ID"); id.IsVisible = false; GridViewTextBoxColumn parentID = new GridViewTextBoxColumn("ParentID"); parentID.IsVisible = false; GridViewTextBoxColumn name = new GridViewTextBoxColumn("Name"); GridViewDateTimeColumn date = new GridViewDateTimeColumn("Date"); GridViewTextBoxColumn type = new GridViewTextBoxColumn("Type"); GridViewTextBoxColumn size = new GridViewTextBoxColumn("Size"); size.FormatString = "{0} MB"; radGridView1.Columns.AddRange(new GridViewDataColumn[] { id, parentID, name, date, type, size }); this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID"); radGridView1.CellValueChanged += radGridView1_CellValueChanged; fillData(); } void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e) { fillData(); } private void fillData() { radGridView1.Rows.Clear(); radGridView1.Rows.Add(1, null, "Program Files", DateTime.Now.AddDays(-100), "Folder", 5120); radGridView1.Rows.Add(2, 1, "Visual Studio 2010", DateTime.Now.AddDays(-100), "Folder", 3220); radGridView1.Rows.Add(3, 2, "bin", DateTime.Now.AddDays(-100), "Folder", 3220); radGridView1.Rows.Add(4, 2, "READEME.txt", DateTime.Now.AddDays(-100), "Text Document", 3); radGridView1.Rows.Add(100, null, "Test.txt", DateTime.Now.AddDays(-10), "Text File", 0); radGridView1.Rows.Add(5, 1, "Telerik RadControls", DateTime.Now.AddDays(-10), "Folder", 3120); radGridView1.Rows.Add(6, 5, "Telerik UI for Winforms", DateTime.Now.AddDays(-10), "Folder", 101); radGridView1.Rows.Add(7, 5, "Telerik UI for Silverlight", DateTime.Now.AddDays(-10), "Folder", 123); radGridView1.Rows.Add(8, 5, "Telerik UI for WPF", DateTime.Now.AddDays(-10), "Folder", 221); radGridView1.Rows.Add(9, 5, "Telerik UI for ASP.NET AJAX", DateTime.Now.AddDays(-10), "Folder", 121); radGridView1.Rows.Add(10, 1, "Microsoft Office 2010", DateTime.Now.AddDays(-120), "Folder", 1230); radGridView1.Rows.Add(11, 10, "Microsoft Word 2010", DateTime.Now.AddDays(-120), "Folder", 1230); radGridView1.Rows.Add(12, 10, "Microsoft Excel 2010", DateTime.Now.AddDays(-120), "Folder", 1230); radGridView1.Rows.Add(13, 10, "Microsoft Powerpoint 2010", DateTime.Now.AddDays(-120), "Folder", 1230); radGridView1.Rows.Add(14, 1, "Debug Diagnostic Tools v1.0", DateTime.Now.AddDays(-400), "Folder", 2120); radGridView1.Rows.Add(15, 1, "Designer's 3D Tools", DateTime.Now.AddDays(-500), "Folder", 1120); radGridView1.Rows.Add(16, 1, "Communication", DateTime.Now.AddDays(-700), "Folder", 120); } Then start the application edit a value and click another cell. Workaround: - Enclose the rows addition within Begin/End update block.