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: use the following code snippet and try to filter the second column: public Form1() { InitializeComponent(); this.radGridView1.Columns.Add("Id"); GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn(); dateTimeColumn.FilteringMode = GridViewTimeFilteringMode.Date; dateTimeColumn.Name = "NullDateTimeColumn"; dateTimeColumn.HeaderText = "Order date"; dateTimeColumn.FieldName = "OrderDate"; dateTimeColumn.FormatString = "{0:dd/MM/yyyy}"; this.radGridView1.Columns.Add(dateTimeColumn); dateTimeColumn = new GridViewDateTimeColumn(); dateTimeColumn.FilteringMode = GridViewTimeFilteringMode.Date; dateTimeColumn.Name = "DateTimeColumn"; dateTimeColumn.HeaderText = "Not Null Date date"; dateTimeColumn.FieldName = "NotNullDate"; dateTimeColumn.FormatString = "{0:dd/MM/yyyy}"; this.radGridView1.Columns.Add(dateTimeColumn); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < 50; i++) { if (i % 2 == 0) { this.radGridView1.Rows.Add(new object[] { i, null, DateTime.Today }); } else { this.radGridView1.Rows.Add(new object[] { i, DateTime.Now.AddDays(i), DateTime.Today }); } } this.radGridView1.EnableFiltering = true; this.radGridView1.MasterTemplate.ShowHeaderCellButtons = true; this.radGridView1.MasterTemplate.ShowFilteringRow = false; } private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e) { e.FilterPopup = new RadListFilterPopup(e.Column, true); } Workaround: use a specific DateTime value instead of null (e.g. 1/1/1800) and use the CellFormatting event to clear the displayed text. Afterwards, in the RadListFilterPopup it is necessary to hide the text for the null value date nodes: public Form1() { InitializeComponent(); this.radGridView1.Columns.Add("Id"); GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn(); dateTimeColumn.FilteringMode = GridViewTimeFilteringMode.Date; dateTimeColumn.Name = "NullDateTimeColumn"; dateTimeColumn.HeaderText = "Order date"; dateTimeColumn.FieldName = "OrderDate"; dateTimeColumn.FormatString = "{0:dd/MM/yyyy}"; this.radGridView1.Columns.Add(dateTimeColumn); dateTimeColumn = new GridViewDateTimeColumn(); dateTimeColumn.FilteringMode = GridViewTimeFilteringMode.Date; dateTimeColumn.Name = "DateTimeColumn"; dateTimeColumn.HeaderText = "Not Null Date date"; dateTimeColumn.FieldName = "NotNullDate"; dateTimeColumn.FormatString = "{0:dd/MM/yyyy}"; this.radGridView1.Columns.Add(dateTimeColumn); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < 50; i++) { if (i % 2 == 0) { this.radGridView1.Rows.Add(new object[] { i, new DateTime(1800, 1, 1), DateTime.Today }); } else { this.radGridView1.Rows.Add(new object[] { i, DateTime.Now.AddDays(i), DateTime.Today }); } } this.radGridView1.EnableFiltering = true; this.radGridView1.MasterTemplate.ShowHeaderCellButtons = true; this.radGridView1.MasterTemplate.ShowFilteringRow = false; } private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e) { RadListFilterPopup popup = new RadListFilterPopup(e.Column, true); e.FilterPopup = popup; popup.PopupOpened += popup_PopupOpened; } private void popup_PopupOpened(object sender, EventArgs args) { RadListFilterPopup popup = sender as RadListFilterPopup; if (popup != null) { popup.MenuTreeElement.TreeView.NodeFormatting += TreeView_NodeFormatting; popup.MenuTreeElement.TreeView.Focus(); } } private void TreeView_NodeFormatting(object sender, TreeNodeFormattingEventArgs e) { if (e.NodeElement.ContentElement.Text.Contains("1800")) { e.NodeElement.ContentElement.DrawText = false; e.NodeElement.ExpanderElement.Opacity = 0; e.NodeElement.ExpanderElement.ShouldHandleMouseInput = false; e.NodeElement.ShouldHandleMouseInput = false; } else { e.NodeElement.ContentElement.DrawText = true; e.NodeElement.ExpanderElement.Opacity = 1; e.NodeElement.ExpanderElement.ShouldHandleMouseInput = true; e.NodeElement.ShouldHandleMouseInput = true; } } private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) { GridViewDateTimeColumn dtCol = e.Column as GridViewDateTimeColumn; if (e.Row is GridViewDataRowInfo && dtCol != null && ((DateTime)e.CellElement.Value).Year == 1800) { e.CellElement.Text = string.Empty; } }
Workaround this.radGridView1.Templates["MyEmptyTemplate"]..AddNewRowPosition = SystemRowPosition.Top Then handle the ViewCellFormatting event and get notifications when the hierarchy tabs are being clicked. private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { GridDetailViewCellElement detailCell = e.CellElement as GridDetailViewCellElement; if (detailCell != null) { detailCell.PageViewElement.ItemSelected -= PageViewElement_ItemSelected; detailCell.PageViewElement.ItemSelected += PageViewElement_ItemSelected; } } private void PageViewElement_ItemSelected(object sender, RadPageViewItemSelectedEventArgs e) { if (e.SelectedItem.Text == "MyEmptyTemplate") { this.SetsGridViewTemplate.AddNewRowPosition = SystemRowPosition.Bottom; } }
To reproduce: use the attached sample project. Follow the steps illustrated on the attached gif file. Workaround: keep the vertical scrollbar value and maximum before modifying the child rows and restore them afterwards: private void gridViewParameter_CellValueChanged(object sender, GridViewCellEventArgs e) { if (e.Column.Name == "Select") { this.gridViewParameter.CellValueChanged -= gridViewParameter_CellValueChanged; GridViewRowInfo selectedRowinfo = e.Row; if (selectedRowinfo.HasChildRows()) { int scrollValue = this.gridViewParameter.TableElement.VScrollBar.Value; int scrollMax = this.gridViewParameter.TableElement.VScrollBar.Maximum; this._UpdateUiState(selectedRowinfo.ChildRows, Convert.ToBoolean(selectedRowinfo.Cells["Select"].Value)); this.gridViewParameter.TableElement.VScrollBar.Maximum = scrollMax; this.gridViewParameter.TableElement.VScrollBar.Value = scrollValue; } this.gridViewParameter.CellValueChanged += gridViewParameter_CellValueChanged; } } NOTE: after applying the workaround, there is annoying flickering illustrated on the Flickering.gif file which should be handled if possible.
To reproduce: 1.Populate RadGridView with data and enable Excel-like filtering. 2.Click on a column filter icon and type in the Search textbox so more than two results appear. Then, click OK 2.The grid returns correct result. 3. Click on the previous column filter icon and navigate to Available Filters -> Contains 4. Evaluate the initial pop up dialog. Its conditions should be "Contains" and "Contains". Actually, it shows "Equals" and "Equals" according to the available filter. Workaround:By using the CreateCompositeFilterDialog event you can replace the default CompositeFilterForm with your custom one where you can load the selected filter operators.
To reproduce: use the following code snippet and have a look at the attached gif file. Steps: 1.Populate RadGridView with data and enable Excel-like filtering. 2.Click on a column filter icon and type in the Search textbox so more than two results appear. Then, click OK 2.The grid returns correct result. 3. Click on the previous column filter icon and navigate to Available Filters -> Contains 4. Evaluate the initial pop up dialog. You will notice that the 3rd filter descriptor is not displayed in the form. 5. Then, click OK 6. A message that says: "The composite filter descriptor is not valid". 7. Change the latter condition to "No filter" and click OK 8. The grid returns correct result. CompositeFilterForm should be improved on a way to display all applied filters,not only two of them. public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Group", typeof(string)); dt.Columns.Add("Description", typeof(string)); for (int i = 0; i < 20; i++) { dt.Rows.Add(GenerateWord(3), "Description"); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableFiltering = true; this.radGridView1.ShowHeaderCellButtons = true; this.radGridView1.ShowFilteringRow = false; this.radGridView1.CreateCompositeFilterDialog += radGridView1_CreateCompositeFilterDialog; } string word = null; int cons; int vow; //counter int i = 0; bool isword = false; Random rand = new Random(); //set a new string array of consonants string[] consonant = new string[] { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z" }; //set a new string array of vowels string[] vowel = new string[] { "a", "e", "i", "o", "u" }; string GenerateWord(int length) { if (length < 1) // do not allow words of zero length throw new ArgumentException("Length must be greater than 0"); string word = string.Empty; if (rand.Next() % 2 == 0) // randomly choose a vowel or consonant to start the word word += consonant[rand.Next(0, 20)]; else word += vowel[rand.Next(0, 4)]; for (int i = 1; i < length; i += 2) // the counter starts at 1 to account for the initial letter { // and increments by two since we append two characters per pass string c = consonant[rand.Next(0, 20)]; string v = vowel[rand.Next(0, 4)]; if (c == "q") // append qu if the random consonant is a q word += "qu"; else // otherwise just append a random consant and vowel word += c + v; } // the word may be short a letter because of the way the for loop above is constructed if (word.Length < length) // we'll just append a random consonant if that's the case word += consonant[rand.Next(0, 20)]; return word; } Workaround: By using the CreateCompositeFilterDialog event you can replace the default CompositeFilterForm with your custom one where you can load all available filter descriptors.
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; } }
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; } }
The idea is that one can bring into view a certain row.
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: 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: Set RadGridView MultiSelect property to true and select several rows. Export RadGridView using GridViewSpreadExport and only current row will be preserved(all selected rows are lost). Workaround: Save all selected rows in a collection before the export and after it set saved rows as selected. List<GridViewRowInfo> selectedRows = new List<GridViewRowInfo>(); foreach (GridViewRowInfo row in this.radGridView1.SelectedRows) { selectedRows.Add(row); } // Export foreach (GridViewRowInfo row in selectedRows) { row.IsSelected = true; }
Workaround: handle the KeyDown event of the inner TextBoxControl and manipulate the TextBox.SelectionStart: private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e) { PropertyGridDropDownListEditor ddlEditor = e.Editor as PropertyGridDropDownListEditor; if (ddlEditor != null) { ddlEditor.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown; BaseDropDownListEditorElement el = ddlEditor.EditorElement as BaseDropDownListEditorElement; el.EditableElement.TextBox.TextBoxItem.TextBoxControl.KeyDown -= el_KeyDown; el.EditableElement.TextBox.TextBoxItem.TextBoxControl.KeyDown += el_KeyDown; } } private void el_KeyDown(object sender, KeyEventArgs e) { TextBox tb = sender as TextBox; if (e.KeyData == Keys.Left && tb.SelectionStart > 0) { tb.SelectionStart = --tb.SelectionStart; } if (e.KeyData == Keys.Right && tb.SelectionStart <= tb.Text.Length) { tb.SelectionStart = ++tb.SelectionStart; } }
To reproduce: - Enable the alternating row color and change the current cell as fast as you can. Workaround: void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e) { if (e.RowElement.RowInfo.Index %2 ==0) { e.RowElement.DrawFill = true; e.RowElement.GradientStyle = GradientStyles.Solid; e.RowElement.BackColor = Color.Aqua; } else { e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local); e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local); e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local); } }
To reproduce: public RadForm1() { InitializeComponent(); radGridView1.AutoGenerateColumns = false; GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn(); decimalColumn.DataType = typeof(int); decimalColumn.Name = "DecimalColumn"; decimalColumn.HeaderText = "DecimalColumn"; decimalColumn.FieldName = "Dosage"; decimalColumn.Width = 200; radGridView1.MasterTemplate.Columns.Add(decimalColumn); radGridView1.DataSource = GetTable(); radGridView1.CellValidating += radGridView1_CellValidating; } void radGridView1_CellValidating(object sender, CellValidatingEventArgs e) { int value = Convert.ToInt32(e.Value); } Workaround: void radGridView1_CellValidating(object sender, CellValidatingEventArgs e) { int value = Convert.ToInt32(e.Value); }
Workaround: public partial class Form1: Form { public Form1() { InitializeComponent(); this.radGridView1.GridViewElement.EditorManager = new MyGridViewEditManager(this.radGridView1.GridViewElement); } } public class MyGridViewEditManager : GridViewEditManager { public MyGridViewEditManager(RadGridViewElement gridViewElement) : base(gridViewElement) { } public override bool BeginEdit() { this.GridViewElement.CurrentView.EnsureCellVisible(this.GridViewElement.CurrentCell.RowInfo, this.GridViewElement.CurrentCell.ColumnInfo); this.GridViewElement.CurrentCell.UpdateLayout(); return base.BeginEdit(); } }
(Two related issues) 1) If I call method RunExport(@"C:\Temp\Foo.xml") on an instance of ExportToExcelML, it creates a file called "C:\Temp\Foo.xls" (notice the change of the file extension). 2) But "*.xls" is the wrong file extension, causing Excel to produce a "The file format and extension of 'Foo.xls' don't match..." warning when the file is opened. This warning does not appear if the file is saved as "*.xml". My suggestion: 1) Keep any given file extension in ExportToExcelML.RunExport(..) 2) Adjust the intellisense help text of the RunExport-method accordingly that it mentions the possibility to save the file with extension ".xml" to avoid the said excel warning but with the drawback that this file extension is not exclusively associated with Excel.
The example found here http://www.telerik.com/support/kb/winforms/gridview/details/high-performance-with-radgridview-and-virtual-mode-including-filtering-sorting-and-grouping, currently does not work. There should be a way for the example virtual grid to go past the current limitation in sorting, filtering and grouping.