To reproduce: Dim RadGridView1 As New RadGridView Me.Controls.Add(RadGridView1) RadGridView1.Dock = DockStyle.Fill Dim r As New Random() Dim table As New DataTable() table.Columns.Add("ID", GetType(Integer))
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); } }
Description: hover the last row bottom border in such a way to display re-sizing cursor. Then move the cursor downwards. The problem occurs only when you have a few rows and move the cursor to the blank side of the grid view. To reproduce: -add RadGridView and use the following code: private void Form1_Load(object sender, EventArgs e) { this.customersTableAdapter.Fill(this.nwindDataSet.Customers); foreach (DataColumn column in this.nwindDataSet.Customers.Columns) { this.radGridView1.Columns.Add(column.ColumnName); } object[] row = this.nwindDataSet.Customers.Rows[0].ItemArray; this.radGridView1.Rows.Add(row); this.radGridView1.SelectedRows[0].IsSelected = false; this.radGridView1.CurrentCell.IsCurrent = false; this.radGridView1.CurrentRow.IsCurrent = false; } Workaround: public Form1() { InitializeComponent(); this.radGridView1.GridBehavior = new MyBaseBehavior(); } public class MyBaseBehavior : BaseGridBehavior { public override bool OnMouseMove(MouseEventArgs e) { GridRowElement currentRow = this.RowAtPoint; if (currentRow == null && e.Button == MouseButtons.None && Cursor.Current != Cursors.Default) { Cursor.Current = Cursors.Default; } return base.OnMouseMove(e); } }
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 a GridViewImageColumn and set its FieldName to something that returns an empty string. You will notice that in the output window numerous first chance exceptions are being thrown.
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); }
To reproduce: public Form1() { InitializeComponent(); InitializeRadGridView(); this.Size = new System.Drawing.Size(782, 647); radGridView1.DataSource = GetDataSource(); radGridView1.MasterTemplate.ExpandAll(); } private void InitializeRadGridView() { radGridView1.EnableGrouping = false; radGridView1.AllowAddNewRow = false; radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; GridViewDataColumn column = new GridViewTextBoxColumn(); column.FieldName = "Name"; radGridView1.MasterTemplate.Columns.Add(column); GridViewTemplate template = new GridViewTemplate(); template.AllowCellContextMenu = false; template.AllowColumnHeaderContextMenu = false; template.AutoGenerateColumns = false; template.ShowRowHeaderColumn = false; template.ShowColumnHeaders = false; template.AllowAddNewRow = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.Templates.Add(template); GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate, template); relation.ChildColumnNames.Add("Bs"); radGridView1.Relations.Add(relation); column = new GridViewTextBoxColumn(); column.FieldName = "Name"; radGridView1.Templates[0].Columns.Add(column); column = new GridViewImageColumn(); column.MinWidth = column.MaxWidth = 30; radGridView1.Templates[0].Columns.Add(column); radGridView1.Templates[0].AllowRowReorder = true; template = new GridViewTemplate(); template.AllowCellContextMenu = false; template.AllowColumnHeaderContextMenu = false; template.AutoGenerateColumns = false; template.ShowRowHeaderColumn = false; template.ShowColumnHeaders = false; template.AllowAddNewRow = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.Templates[0].Templates.Add(template); relation = new GridViewRelation(radGridView1.Templates[0], template); relation.ChildColumnNames.Add("Cs"); radGridView1.Relations.Add(relation); column = new GridViewTextBoxColumn(); column.FieldName = "Name"; radGridView1.Templates[0].Templates[0].Columns.Add(column); radGridView1.Templates[0].Templates[0].AllowRowReorder = true; } private List<A> GetDataSource() { List<A> list = new List<A>(); A a1 = new A(); a1.Id = 1; a1.Name = "A1"; list.Add(a1); A a2 = new A(); a2.Id = 2; a2.Name = "A2"; list.Add(a2); A a3 = new A(); a3.Id = 3; a3.Name = "A3"; list.Add(a3); B b1 = new B(); b1.Id = 10; b1.Name = "B1"; a1.Bs.Add(b1); B b2 = new B(); b2.Id = 20; b2.Name = "B2"; a1.Bs.Add(b2); B b3 = new B(); b3.Id = 30; b3.Name = "B3"; a1.Bs.Add(b3); B b4 = new B(); b4.Id = 40; b4.Name = "B4"; a2.Bs.Add(b4); B b5 = new B(); b5.Id = 50; b5.Name = "B5"; a3.Bs.Add(b5); C c1 = new C(); c1.Id = 100; c1.Name = "C1"; b1.Cs.Add(c1); b3.Cs.Add(c1); C c2 = new C(); c2.Id = 200; c2.Name = "C2"; b1.Cs.Add(c2); b2.Cs.Add(c2); b2.Cs.Add(c1); C c3 = new C(); c3.Id = 300; c3.Name = "C3"; b1.Cs.Add(c3); b2.Cs.Add(c3); b3.Cs.Add(c3); C c4 = new C(); c4.Id = 400; c4.Name = "C4"; b4.Cs.Add(c4); C c5 = new C(); c5.Id = 500; c5.Name = "C5"; b5.Cs.Add(c5); return list; } } public class A { public int Id { get; set; } public string Name { get; set; } public List<B> Bs { get; set; } public A() { Bs = new List<B>(); } } public class B { public int Id { get; set; } public string Name { get; set; } public List<C> Cs { get; set; } public B() { Cs = new List<C>(); } } public class C { public int Id { get; set; } public string Name { get; set; } } The last row is not fully visible, hence a scroll bar should be shown Workaround: collapse and expand the last row in the grid: radGridView1.MasterTemplate.ExpandAll(); radGridView1.ChildRows[radGridView1.ChildRows.Count - 1].IsExpanded = false; radGridView1.ChildRows[radGridView1.ChildRows.Count - 1].IsExpanded = true;
To Reproduce: - Add GridViewCalculatorColumn to a RadGridView. - When you begin edit a cell the value is not selected. Workaround: Create a custom RadCalculatorEditor and then change the editor in EditorRequired event: void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e) { if (e.EditorType.Name == "RadCalculatorEditor") { e.Editor = new CustomCalculatorEditor(); } } public class CustomCalculatorEditor : RadCalculatorEditor { public override void BeginEdit() { base.BeginEdit(); RadCalculatorDropDownElement editorElement = this.EditorElement as RadCalculatorDropDownElement; editorElement.EditorContentElement.TextBoxItem.SelectAll(); } }
To reproduce: Add page view, add a tab, add a grid, dispose the controls inside the tab on its removing event. Exception may occur.
To reproduce use this code: public partial class Form1 : Form { RadGridView radGridView1 = new RadGridView(); public Form1() { InitializeComponent(); this.Controls.Add(this.radGridView1); this.radGridView1.Dock = DockStyle.Fill; this.radGridView1.AutoGenerateColumns = false; this.radGridView1.TableElement.RowHeight = 30; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.AddNewRowPosition = SystemRowPosition.Bottom; this.radGridView1.EnterKeyMode = RadGridViewEnterKeyMode.EnterMovesToNextCell; this.radGridView1.NewRowEnterKeyMode = RadGridViewNewRowEnterKeyMode.EnterMovesToNextCell; this.radGridView1.BeginEditMode = Telerik.WinControls.RadGridViewBeginEditMode.BeginEditOnKeystrokeOrF2; this.radGridView1.EnableGrouping = false; this.radGridView1.EnableAlternatingRowColor = true; this.radGridView1.AllowAddNewRow = true; this.radGridView1.AllowEditRow = true; this.radGridView1.AllowDeleteRow = true; this.radGridView1.EnableFiltering = true; this.radGridView1.EnableSorting = true; ArrayList arrayList = new ArrayList(); arrayList.Add(new Person() { Name = "Jack", Family = "J..." }); arrayList.Add(new Person() { Name = "Bob", Family = "B..." }); arrayList.Add(new Person() { Name = "Dani", Family = "D..." }); radGridView1.Columns.Add("ColName", "Name", "Name"); radGridView1.Columns.Add("ColFamily", "Family", "Family"); radGridView1.DataSource = arrayList; this.radGridView1.CellValidating +=radGridView1_CellValidating; } private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e) { GridViewDataColumn column = e.Column as GridViewDataColumn; if ((e.Row is GridViewDataRowInfo || e.Row is GridViewNewRowInfo) && column != null && (column.Name == "ColName")) { if (e.Value == null || ((string)e.Value).Trim() == "") if (string.IsNullOrEmpty ((string)e.Value) || ((string)e.Value).Trim() == string.Empty || string.IsNullOrWhiteSpace ((string)e.Value)) { if (e.ActiveEditor != null) { MessageBox.Show("Please enter your name"); e.Cancel = true; } } } } } public class Person { private string name; private string family; public string Name { get { return name; } set { name = value; } } public string Family { get { return family; } set { family = value; } } } Try to add a new row by clicking the cell of the first column and leaving it empty. You will see the messagebox twice. Workaround: public class MyGridRowBehavior : GridNewRowBehavior { protected override bool ProcessEnterKey(KeyEventArgs keys) { GridViewNewRowInfo newRowInfo = (GridViewNewRowInfo)this.GridViewElement.CurrentRow; if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.EnterMovesToNextCell) { bool editorClosed = !this.IsInEditMode; if (this.IsInEditMode) { if (this.IsOnLastCell()) { if (newRowInfo != null) { newRowInfo.GetType().GetMethod("DeferUserAddedRow", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(newRowInfo, null); } editorClosed = GridViewElement.EndEdit(); } else { editorClosed = GridViewElement.CloseEditor(); } } if (editorClosed) { this.Navigator.SelectNextColumn(); this.GridViewElement.BeginEdit(); } if (this.IsInEditMode && this.GridViewElement.CurrentRow is GridViewNewRowInfo && this.GridViewElement.BeginEditMode != RadGridViewBeginEditMode.BeginEditProgrammatically) { return this.GridViewElement.BeginEdit(); } if (newRowInfo != null) { newRowInfo.GetType().GetMethod("RaiseUserAddedRow", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(newRowInfo, null); } return false; } return base.ProcessEnterKey(keys); } } ((BaseGridBehavior)this.radGridView1.GridBehavior).UnregisterBehavior(typeof(GridViewNewRowInfo)); ((BaseGridBehavior)this.radGridView1.GridBehavior).RegisterBehavior(typeof(GridViewNewRowInfo), new MyGridRowBehavior());
To reproduce: void grid_RowValidating(object sender, RowValidatingEventArgs e) { e.Cancel = true; } Pressing the escape key should cancel the edit mode and revert the value
To reproduce: this.grid.Columns.Add(new GridViewDecimalColumn("col")); for (int i = 0; i < 5; i++) { this.grid.Rows.Add(i); } GridViewSummaryItem stDev = new GridViewSummaryItem() { Name = "col", Aggregate = GridAggregateFunction.Var // or GridAggregateFunction.StDev }; var row = new GridViewSummaryRowItem(); row.Add(stDev); this.grid.SummaryRowsTop.Add(row); This will throw an exception.
There should be a convenient and more straightforward API for accessing the TableElement of a child gridview. Currently, the API is: void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { if (e.CellElement is GridDetailViewCellElement) { ((GridDetailViewCellElement)e.CellElement).ChildTableElement.RowHeight = 50; } }
To reproduce: - Create a RadGridView with 3 columns. - Set ShowRowHeaderColumn to false. - Set GridViewAutoSizeColumnsMode to Fill. - Select a cell and hit the TAB key multiple times. Notice the entire grid shift left and right.
To reproduce: - Add CommandColumn to the grid - Observe the size of the button in the newrow row Workaround: - Add some padding in the cell formating event void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) { GridViewNewRowInfo row = e.Row as GridViewNewRowInfo; GridCommandCellElement cell = e.CellElement as GridCommandCellElement; if (row != null && cell != null) { cell.CommandButton.SetDefaultValueOverride(RadItem.MarginProperty, new System.Windows.Forms.Padding(0,0,1,0)); } }
To reproduce: - Create a GridViewMaskBoxColumn with standard mask type and mask set to "aaaaaaaaaa". - Bind the grid to the following DataTable: private static DataTable GridDataTable() { DataRow dr = default(DataRow); DataTable dt = new DataTable(); dt.Columns.Add("Description"); dr = dt.NewRow(); dr[0] = "1234567890"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "abc"; dt.Rows.Add(dr); return dt; } - Click the first cell in order to enter in edit mode. - Click the second cell and you will notice that the text is wrong. Workaround: - change the value in the CellEditor intialized event handler: void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { if (e.ActiveEditor is RadMaskedEditBoxEditor) { RadMaskedEditBoxEditor editor = e.ActiveEditor as RadMaskedEditBoxEditor; editor.MaskTextBox.Value = "___________"; editor.MaskTextBox.Value = (string)radGridView1.CurrentCell.Value; } }
To reproduce: Create a project with RadGridView, add some rows, make sure you have space to perform panning. Pan up and down, exception should occur. Workaround : radgridView1.ViewDefinition = new MyTableViewDefinition(); public class MyTableViewDefinition : TableViewDefinition { public override IRowView CreateViewUIElement(GridViewInfo viewInfo) { return new MyGridTableElement(); } } public class MyGridTableElement : GridTableElement { protected override void OnPanGesture(Telerik.WinControls.PanGestureEventArgs args) { //base.OnPanGesture(args) -> you can stop touch support by also not calling the base and leaving this method empty if (args.IsBegin && (this.RowScroller.Scrollbar.ControlBoundingRectangle.Contains(args.Location) || this.ColumnScroller.Scrollbar.ControlBoundingRectangle.Contains(args.Location) || this.ViewElement.TopPinnedRows.ControlBoundingRectangle.Contains(args.Location))) { return; } bool containsCurrent = (this.GridViewElement.CurrentRow == null && this.GridViewElement.Template == this.ViewTemplate); if (!containsCurrent) { foreach (IRowView child in this.GridViewElement.GetRowViews(this.GridViewElement.CurrentRow.ViewInfo)) { containsCurrent |= (child == this); } } if (!containsCurrent) { return; } this.GridViewElement.EndEdit(); int newVerticalValue = this.RowScroller.Scrollbar.Value - args.Offset.Height; if (newVerticalValue > this.RowScroller.Scrollbar.Maximum - this.RowScroller.Scrollbar.LargeChange + 1) { newVerticalValue = this.RowScroller.Scrollbar.Maximum - this.RowScroller.Scrollbar.LargeChange + 1; } if (newVerticalValue < this.RowScroller.Scrollbar.Minimum) { newVerticalValue = this.RowScroller.Scrollbar.Minimum; } RadScrollBarElement rowScrollbar = this.RowScroller.Scrollbar; if (newVerticalValue > rowScrollbar.Maximum) { newVerticalValue = rowScrollbar.Maximum; } else if (newVerticalValue < 0) { newVerticalValue = 0; } this.RowScroller.Scrollbar.Value = newVerticalValue; int newHorizontalValue = this.ColumnScroller.Scrollbar.Value - args.Offset.Width; if (newHorizontalValue > this.ColumnScroller.Scrollbar.Maximum - this.ColumnScroller.Scrollbar.LargeChange + 1) { newHorizontalValue = this.ColumnScroller.Scrollbar.Maximum - this.ColumnScroller.Scrollbar.LargeChange + 1; } if (newHorizontalValue < this.ColumnScroller.Scrollbar.Minimum) { newHorizontalValue = this.ColumnScroller.Scrollbar.Minimum; } RadScrollBarElement columnScrollBar = this.ColumnScroller.Scrollbar; if (newHorizontalValue > columnScrollBar.Maximum) { newHorizontalValue = columnScrollBar.Maximum; } else if (newHorizontalValue < 0) { newHorizontalValue = 0; } this.ColumnScroller.Scrollbar.Value = newHorizontalValue; args.Handled = true; } }
FIX. RadGridView ComboBoxColumn when in data bound mode with auto complete set to SuggestAppend wrong results might be obtained. How to reporduce: Use RadGridView with ComboBoxColumn and set AutoCompleteMode to SuggestAppend. Also set DropDownStyle to DropDown. When start typing if nonexisting item gets typed the column will append the closest available item to the cell.
RadGridView If FilteringMode is set to DisplayMember if one clicks in the ComboBoxColumn cell; the actual cell value goes blank. If FilteringMode is set to ValueMember the ComboBoxColumn behaves as expected. Workaround: Private Sub RadGridView1_CellEditorInitialized(sender As Object, e As GridViewCellEventArgs) Handles RadGridView1.CellEditorInitialized If e.ActiveEditor.GetType() Is GetType(RadDropDownListEditor) Then e.ActiveEditor.Value = e.Value End If End Sub
Steps to reproduce: 1. Add two classes to the project: public class ParentClass { public int MyProperty { get; set; } public List<ChildClass> Children { get; set; } } public class ChildClass { public int MyProperty { get; set; } public SomeEnum Enumera { get; set; } } public enum SomeEnum { first, second, third } 2. Add two RadGridViews to a form. 3. Add two binding sources one with DataSource the ParentClass, the second with DataSource the first binding source and DataMember "Children" 4. Bind the grids to the two data sources. 5. Edit some column properties of the grid bound to the second data source. 6. Build the project and try to open the smart tag of the grid. Some times you will see a message box with text "Object does not match target type."