To reproduce: Add a RadGridView wth a few columns ,add rows as a few rows should have increasingly long text. Right click on the header cell to show the context menu and click bestfit. You will notice that the size of the column is not correct Workaround: void grid_MouseMove(object sender, MouseEventArgs e) { this.mouseLocation = e.Location; } private Point mouseLocation; private GridViewColumn currentColumn; void grid_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { if (this.grid.CurrentRow is GridViewHierarchyRowInfo) { RadItem bestFitItem = e.ContextMenu.Items.FirstOrDefault(x => x.Text == "Best Fit"); if (bestFitItem != null) { e.ContextMenu.Items.Remove(bestFitItem); } RadMenuItem newBestFitItem = new RadMenuItem { Text = "Best Fit" }; this.currentColumn = (this.grid.ElementTree.GetElementAtPoint(this.mouseLocation) as GridCellElement).ColumnInfo; newBestFitItem.Click += newBestFitItem_Click; e.ContextMenu.Items.Add(newBestFitItem); } } void newBestFitItem_Click(object sender, EventArgs e) { int highestWidth = this.GetHeightestWidthFromColumn(this.currentColumn); this.currentColumn.Width = highestWidth; } private int GetHeightestWidthFromColumn(GridViewColumn gridViewColumn) { int max = int.MinValue; Font cellFont = this.grid.TableElement.VisualRows[0].VisualCells[0].Font; for (int i = 0; i < this.grid.Rows.Count; i++) { int textWidth = TextRenderer.MeasureText(this.grid.Rows[i].Cells[gridViewColumn.Index].Value + "", cellFont).Width; if (max < textWidth) { max = textWidth; } } return max; }
Add the ability to access the ColumnChooser opening in order to set its properties. Currently, every time when the user opens the ColumnChoser new instance is created and because of this its properties and events are no longer available. This feature will Resolution: Add the ColumnChooserCreated event which access and allow to customize the ColumnChooser. //subscribe to the event ColumnChooserCreated this.radGridView1.ColumnChooserCreated += new ColumnChooserCreatedEventHandler(radGridView1_ColumnChooserCreated); //customize the ColumnChooser void radGridView1_ColumnChooserCreated(object sender, Telerik.WinControls.UI.ColumnChooserCreatedEventArgs e) { e.ColumnChooser.ForeColor = Color.DarkGreen; e.ColumnChooser.Text = "My title"; e.ColumnChooser.ColumnChooserControl.ColumnChooserElement.Font = this.Font; e.ColumnChooser.ColumnChooserControl.ColumnChooserElement.Text = "My text"; }
To reproduce: - Subscribe to the grids KeyDown event. - You will notice that KeyDown event is not fired when the control key is pressed. Workaround: - Use the KeyUp event instead. - Also setting the ClipboardCopyMode property to disabled will activate the event for this case.
The row's MaxHeight property does not affect the row sizing when the AutoSizeRows property of RadGridView is enabled. Workaround: Use the following data row: public class MyGridDataRowElement : GridDataRowElement { protected override Type ThemeEffectiveType { get { return typeof(GridDataRowElement); } } protected override System.Drawing.SizeF MeasureCore(System.Drawing.SizeF availableSize) { float maxHeight = this.RowInfo.MaxHeight; bool isAutoSize = this.GridViewElement.AutoSize && this.RowInfo.MaxHeight > 0 && availableSize.Height == float.PositiveInfinity; SizeF size = base.MeasureCore(availableSize); if (isAutoSize && size.Height > maxHeight) { availableSize.Height = maxHeight; size = base.MeasureCore(availableSize); } return size; } } here is how to replace it and set the max height: void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e) { e.RowElement.RowInfo.MaxHeight = 32; } void radGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e) { if (e.RowType == typeof(GridDataRowElement)) { e.RowType = typeof(MyGridDataRowElement); } }
Description: Just use the button x times to show an additional form with a RadGridView Control on it. RadGridView is not releasing the complete allocated memory. JustTrace shows an increasing number of Telerik.WinControls.RadPropertyValue instances. Resolution: Not a memory leak. When a form is shown with the ShowDialog method, it should be explicitly disposed. If the form was shown using the Show method, the Dispose method does not need to be called explicitly. It will be called automatically when the form is closed. Source: MSDN http://msdn.microsoft.com/en-us/library/aw58wzka%28v=vs.110%29.aspx
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;
has no user validation, exception when the type of parent and child keys is different
When columns are reorder by the user RadGridView should persist these settings through the Save/LoadLayout routines.
To reproduce: - Add a checkbox column to a grid - Add the following code to the ValueChanged event: void radGridView1_ValueChanged(object sender, EventArgs e) { if (radGridView1.CurrentColumn.Name == "BoolColumn") {
To reproduce: - add RadGridView and use the following code: public Form1() { InitializeComponent(); List<ColorItem> list = new List<ColorItem>(); List<Color> colors = new List<Color>() { Color.Red, Color.Black, Color.Blue, Color.Pink, Color.Green, Color.Yellow, Color.Purple, Color.Aqua, Color.Orange, Color.Fuchsia }; for (int i = 0; i < 10; i++) { list.Add(new ColorItem(i, colors[i], colors[i].Name)); } radGridView1.DataSource = list; radGridView1.CellValidating += radGridView1_CellValidating; } private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e) { if (e.ActiveEditor is GridColorPickerEditor && (Color)e.Value == Color.Aqua) { e.Cancel = true; } } Steps: 1. Select the "Color" column of a certain cell and activate the editor; 2. Select Color.Aqua and press Tab to close the currently active GridColorPickerEditor; As a result InvalidCastException is thrown. Workaround: use a custom editor derivative of BaseGridEditor: radGridView1.EditorRequired += radGridView1_EditorRequired; private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e) { if (e.EditorType == typeof(GridColorPickerEditor)) { e.Editor = new CustomColorEditor(); } } public class CustomColorEditor : BaseGridEditor { TypeConverter converter = TypeDescriptor.GetConverter(typeof(Color)); protected override Telerik.WinControls.RadElement CreateEditorElement() { return new GridColorPickerElement(); } public override object Value { get { GridColorPickerElement editorElement = this.EditorElement as GridColorPickerElement; return editorElement.GetColorValue(); } set { GridColorPickerElement editorElement = this.EditorElement as GridColorPickerElement; if (value is Color) { editorElement.SetColorValue((Color)value); } else if (value is string) { editorElement.SetColorValue((Color)converter.ConvertFromString((string)value)); } } } }
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 RadGridView and apply Windows7 theme -click on some GridHeaderCellElement. As a result the arrow is cut off. Workaround: this.radGridView1.ViewCellFormatting+=radGridView1_ViewCellFormatting; private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) { GridHeaderCellElement cell = e.CellElement as GridHeaderCellElement; if (cell != null) { cell.Arrow.Margin = new Padding(0, 3, 0, 0); } }
To reproduce: -add RadGridView and enable excel-like filtering; -apply Windows7 theme When clicking on the filter button, the filter-dialog that shows is not really wide enough, it cuts the Cancel-button. Workaround: this.radGridView1.FilterPopupInitialized += radGridView1_FilterPopupInitialized; private void radGridView1_FilterPopupInitialized(object sender, Telerik.WinControls.UI.FilterPopupInitializedEventArgs e) { e.FilterPopup.PopupOpening -= FilterPopup_PopupOpening; e.FilterPopup.PopupOpening += FilterPopup_PopupOpening; } private void FilterPopup_PopupOpening(object sender, CancelEventArgs args) { RadListFilterPopup popup = sender as RadListFilterPopup; Padding currentPadding = popup.ButtonsMenuItem.Padding; popup.ButtonsMenuItem.Padding = new Padding(currentPadding.Left, currentPadding.Top, 20, currentPadding.Bottom); }
To reproduce: -add RadGridView and RadButton to the form; -apply Office2010Black to the grid; -use the following code: private DataTable dataTable; public Form1() { InitializeComponent(); radGridView1.AutoSizeRows = false; radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.RowFormatting += radGridView1_RowFormatting; radGridView1.ReadOnly = true; radGridView1.ShowRowHeaderColumn = false; radGridView1.VerticalScrollState = ScrollState.AlwaysShow; radGridView1.ThemeName = "Office2010Black"; dataTable = new DataTable(); dataTable.Columns.Add("number", typeof(int)); dataTable.Columns.Add("descriptions", typeof(string)); radGridView1.DataSource = dataTable; } void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e) { e.RowElement.RowInfo.Height = 120; } private void radButton1_Click(object sender, EventArgs e) { radGridView1.Enabled = false; Random rnd = new Random((int)DateTime.Now.Ticks); dataTable.Clear(); for (int i = 0; i < rnd.Next(1000); i++) { DataRow row = dataTable.NewRow(); row[0] = i + 1; row[1] = "description" + i.ToString(); dataTable.Rows.Add(row); } radGridView1.Enabled = true; } After clicking the button, notice that the vertical scroll bar is not painted correctly and it is resized when scrolling. Workaround: Update the button Click event as follows: private void radButton1_Click(object sender, EventArgs e) { radGridView1.VerticalScrollState = ScrollState.AlwaysHide; radGridView1.Enabled = false; radGridView1.BeginEdit(); Random rnd = new Random((int)DateTime.Now.Ticks); dataTable.Clear(); for (int i = 0; i < rnd.Next(1000); i++) { DataRow row = dataTable.NewRow(); row[0] = i + 1; row[1] = "description" + i.ToString(); dataTable.Rows.Add(row); } radGridView1.EndEdit(); radGridView1.Enabled = true; radGridView1.VerticalScrollState = ScrollState.AlwaysShow; radGridView1.TableElement.VScrollBar.ResetLayout(true); radGridView1.MasterTemplate.Refresh(); radGridView1.TableElement.ScrollToRow(radGridView1.CurrentRow); }
I use a BindingList to bind our data to grid. But when I set to this list two classes with common interface but different implementation (override of baseclass virtual property), an data exception error is thrown. The same code works fine in previous versions.
After the delete, the item is removed from the BindingList, but it still appears in the RadGridView (or deleted a wrong item). The binding doesn't trigger the change in the UI/View.
FIX. RadGridView - cursor does not work properly, when cursor has value "Cursors.SizeWE" and mouse is moving over GroupPanelElement. Steps to reproduce: 1. On a gridview make sure that a column in grouped. 2. Place your mouse on a column split just below the grouped column. 3. The cursor icon changes to a SizeWE icon to let you know that you can resize the column, This is normal. 4. Now, move the mouse (with the cursor icon = SizeWE) to the grouped column just above. 5. Now the cusor gets stucked with this SizeWE icon and never goes away on this grid. Wathever you do now the icon stays showing as a SizeWE icon. Work Around - create custom grid behavior and override OnMouseMove method. public class CustomGridBehavior : BaseGridBehavior { public override bool OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); GridTableElement table = this.GetGridTableElementAtPoint(e.Location); if (table == null) { this.GridViewElement.ElementTree.Control.Cursor = Cursors.Default; return false; } return false; } }
Steps to reproduce: 1. Addd a numeric (decimal) column to a grid 2. Enable filtering 3. Select 'Greater Than' filter 4. Enter '0' in the Spin Editor that appears You will see that no filtering occurs. Enter any other digit instead of 0 and filtering is performed.
We should consider the Display attribute when using business objects as data source in RadGridView.
The DefaultValueAttribute of Format and FormatInfo properties of GridViewDataColumn causes exceptions when load layout is performed. Comment: this is an issue inside .Net framework.