To reproduce: radGridView1.DataSource = GetTable(); radGridView1.MultiSelect = true; radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect; Then just select and deselect several cells without releasing the mouse button. Workaround: void radGridView1_MouseUp(object sender, MouseEventArgs e) { int endIndexCol = -1; int endIndexRow = -1; GridDataCellElement curentCell = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement; if (curentCell != null) { endIndexCol = curentCell.ColumnInfo.Index; endIndexRow = curentCell.RowInfo.Index; } if (endIndexCol < startIndexCol) { int temp = endIndexCol; endIndexCol = startIndexCol; startIndexCol = temp; } if (endIndexRow < startIndexRow) { int temp = endIndexRow; endIndexRow = startIndexRow; startIndexRow = temp; } foreach (GridViewCellInfo cell in radGridView1.SelectedCells.ToList()) { if (cell.RowInfo.Index < startIndexRow || cell.RowInfo.Index > endIndexRow) { cell.IsSelected = false; } if (cell.ColumnInfo.Index < startIndexCol || cell.ColumnInfo.Index > endIndexCol) { cell.IsSelected = false; } } } int startIndexCol = -1 ; int startIndexRow = -1; void radGridView1_MouseDown(object sender, MouseEventArgs e) { GridDataCellElement curentCell = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement; if (curentCell != null) { startIndexCol = curentCell.ColumnInfo.Index; startIndexRow = curentCell.RowInfo.Index; } }
To reproduce: GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1); spreadExporter.RunExport(@"C:\exportedFile.xlsx"); Workaround: GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1); spreadExporter.RunExport(@"C:\exportedFile.xlsx", new SpreadExportRenderer()); Alternatively you can set the Copy Local property of the TelerikExport assembly to true.
To reproduce: - Add GridViewDateTimeColumn. - Set the editor properties: private void radGridView_VehicleAbsenceTime_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDateTimeEditor lEditor = radGridView_VehicleAbsenceTime.ActiveEditor as RadDateTimeEditor; if (lEditor != null) { RadDateTimeEditorElement editorElement = (RadDateTimeEditorElement)lEditor.EditorElement; editorElement.Format = DateTimePickerFormat.Custom; editorElement.CustomFormat = "dd.MM.yyyy HH:mm"; editorElement.ShowUpDown = true; } } - Start the application scroll to the bottom and start editing.
To reproduce: 1. Add a GridViewDecimalColumn to a grid with data type int, float, decimal, double, real, money. 2. Add few rows where one of rows contains null value. 3. Run the form. Sort the grid by any of column with null data and you will see that the exception is thrown. Workaround: 1. Use custom TypeConverter public class CustomFloatConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(float); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(float) && (value == null || value is DBNull)) { return float.MinValue; } return value; } } public class CustomIntConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(int); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(int) && (value == null || value is DBNull)) { return int.MinValue; } return value; } } public class CustomDecimalConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(decimal); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(decimal) && (value == null || value is DBNull)) { return decimal.MinValue; } return value; } } public class CustomDoubleConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(double); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(double) && (value == null || value is DBNull)) { return double.MinValue; } return value; } } public class CustomSingleConverter : TypeConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(Single); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(Single) && (value == null || value is DBNull)) { return Single.MinValue; } return value; } } 2. Apply the converter to GridViewDecimalColumn this.radGridView2.Columns["ColumnReal"].DataTypeConverter = new CustomSingleConverter(); this.radGridView2.Columns["ColumnFloat"].DataTypeConverter = new CustomDoubleConverter(); this.radGridView2.Columns["ColumnDecimal"].DataTypeConverter = new CustomDecimalConverter(); this.radGridView2.Columns["ColumnInt"].DataTypeConverter = new CustomIntConverter(); this.radGridView2.Columns["ColumnNumeric"].DataTypeConverter = new CustomDecimalConverter(); this.radGridView2.Columns["ColumnMoney"].DataTypeConverter = new CustomDecimalConverter();
How to reproduce: Public Class Form1 Sub New() InitializeComponent() Dim dataTable As New DataTable dataTable.Columns.Add("Id", GetType(Integer)) dataTable.Columns.Add("Name", GetType(String)) dataTable.Columns.Add("IsValid", GetType(Boolean)) For i As Integer = 0 To 40 dataTable.Rows.Add(i, "Name " & i, i Mod 2 = 0) Next Me.RadGridView1.DataSource = dataTable Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill Me.RadGridView1.TableElement.RowHeight = 20 End Sub Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click Me.RadGridView1.PrintPreview() End Sub End Class Workaround: before printing increase the row height or set RadGridView.AutoSizeRows = True Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click 'Me.RadGridView1.TableElement.RowHeight = 24 Me.RadGridView1.AutoSizeRows = True Me.RadGridView1.PrintPreview() End Sub
1. Use the following code snippet: public Form1() { InitializeComponent(); this.radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.MasterTemplate.EnableAlternatingRowColor = true; this.radGridView1.MasterTemplate.EnableFiltering = true; this.radGridView1.MasterTemplate.MultiSelect = true; for (int i = 0; i < 3; i++) { this.radGridView1.Columns.Add("Col"+i); } radGridView1.Rows.Add("test1", "test1", "test1"); radGridView1.Rows.Add("test2", "test2", "test2"); radGridView1.Rows.Add("test3", "test3", "test3"); radGridView1.Rows.Add("test4", "test4", "test4"); radGridView1.Rows.Add("test5", "test5", "test5"); } 2. Quickly click around the cells a few times, making sure to drag your mouse a bit to select a few rows on some of the clicks. Then quickly click the filter. (sometimes it takes a few tries) Workaround: use custom GridFilterRowBehavior BaseGridBehavior gridBehavior = radGridView1.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewFilteringRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewFilteringRowInfo), new CustomGridFilterRowBehavior()); public class CustomGridFilterRowBehavior : GridFilterRowBehavior { protected override bool ProcessMouseSelection(Point mousePosition, GridCellElement currentCell) { return false; } }
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; } } }
http://screencast.com/t/mZDwbWS8 WORKAROUND: Set the UseCompatibleTextRendering property of RadGridView to false.
Note: if you try to clear the initial minimum value by pressing Backspace or Delete key, the editor value reappears. To reproduce: GridViewDecimalColumn decimalColumn2 = new GridViewDecimalColumn("Col2"); decimalColumn2.FieldName = "Number"; decimalColumn2.Minimum = -50; decimalColumn2.Maximum = 50; radGridView2.MasterTemplate.Columns.Add(decimalColumn2); radGridView2.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView2.EnableFiltering = true; Workaround: private void radGridView2_EditorRequired(object sender, Telerik.WinControls.UI.EditorRequiredEventArgs e) { if (e.EditorType == typeof(GridSpinEditor)) { e.EditorType = typeof(CustomEditor); } } public class CustomEditor : GridSpinEditor { protected override Telerik.WinControls.RadElement CreateEditorElement() { return new CustomElement(); } } public class CustomElement : GridSpinEditorElement { protected override decimal GetValueFromText() { if (string.IsNullOrEmpty(this.Text)) { return this.MinValue; } return base.GetValueFromText(); } }
How to reproduce: public Form1() { InitializeComponent(); string newLine = "line"; string multiLine = "line"; for (int i = 0; i < 10; i++) { radGridView1.Rows.Add(newLine, multiLine); multiLine += Environment.NewLine + multiLine; } this.Load += Form1_Load; } Workaround: private void Form1_Load(object sender, EventArgs e) { this.radGridView1.Columns[1].PropertyChanged += item_PropertyChanged; } private void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "IsVisible") { this.radGridView1.TableElement.ScrollTo(0, 0); } }
Steps to reproduce: 1. Add a GridViewDateTimeColumn to a grid. 2. Add rows where one or more rows should contain null as the columns value. 3. Sort the grid by the date time column. WORKAROUND: Create a custom RadGridDateTimeConverter and assign it as the column's date type converter: public class CustomRadGridDateTimeConverter : RadGridDateTimeConverter { public CustomRadGridDateTimeConverter(GridViewDateTimeColumn column) : base(column) { } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(DateTime) && value == null) { return DateTime.MinValue; } return base.ConvertTo(context, culture, value, destinationType); } } this.radGridView1.Columns["DateTime"].DataTypeConverter = new CustomRadGridDateTimeConverter(this.radGridView1.Columns["DateTime"] as GridViewDateTimeColumn);
Workaround: set the data type of the column to null before saving the layout and after loading it set it with the needed type
Use the following help article to set up the hierarchy >> http://www.telerik.com/help/winforms/gridview-hierarchical-grid-self-referencing-hierarchy.html Please refer to the attached gif files illustrating the behavior in Q1 SP and Q2.
There should be a Enum (Left, Right, None) property of the Expander Column indicating whether the position of the expander column should be left right or none. This would be especially important during pinning activities meaning no matter how many columns are being pinned and repositioned in the pinned area of the grid, it would always remain on the left, right or none.
BindingList<Item> items = new BindingList<Item>(); public Form1() { InitializeComponent(); for (int i = 0; i < 20; i++) { items.Add(new Item(i % 4, "Item" + i, "Type" + i % 2)); } this.radGridView1.DataSource = items; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } public class Item { public int Id { get; set; } public string Name { get; set; } public string Type { get; set; } public Item(int id, string name, string type) { this.Id = id; this.Name = name; this.Type = type; } } private void radButton1_Click(object sender, EventArgs e) { items.Insert(0, new Item(2, "Test", "Type0")); } WORKAROUND I: GridViewSynchronizationService.SuspendEvent(this.radGridView1.MasterTemplate, KnownEvents.CurrentChanged); Item item = new Item(2, "Test", "Type0"); items.Insert(0, item); GridViewSynchronizationService.ResumeEvent(this.radGridView1.MasterTemplate, KnownEvents.CurrentChanged); foreach (GridViewRowInfo row in this.radGridView1.Rows) { if (row.DataBoundItem == item) { this.radGridView1.CurrentRow = row; break; } } WORKAROUND II: this.radGridView1.Rows.CollectionChanged += Rows_CollectionChanged; this.radGridView1.GroupExpanding+=radGridView1_GroupExpanding; List<GridViewRowInfo> expandedGroups = new List<GridViewRowInfo>(); private void radGridView1_GroupExpanding(object sender, GroupExpandingEventArgs e) { if (!e.IsExpanded && shouldCollapse) { expandedGroups.Add(e.DataGroup.GroupRow); } } bool shouldCollapse = false; private void radButton1_Click(object sender, EventArgs e) { shouldCollapse = true; items.Insert(0, new Item(2, "Test", "Type0")); } private void Rows_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add) { this.radGridView1.CurrentRow = e.NewItems[0] as GridViewRowInfo; this.radGridView1.CurrentRow.IsSelected = true; GridViewRowInfo parent = this.radGridView1.CurrentRow.Parent as GridViewRowInfo; if (parent != null) { parent.IsExpanded = true; } if (shouldCollapse) { shouldCollapse = false; foreach (GridViewRowInfo r in expandedGroups) { if (!ContainsParentRow(parent, r)) { r.IsExpanded = false; } } expandedGroups.Clear(); } } } private bool ContainsParentRow(GridViewRowInfo parent, GridViewRowInfo r) { GridViewGroupRowInfo group = r as GridViewGroupRowInfo; if (group != null) { foreach (GridViewRowInfo childRow in group.ChildRows) { return ContainsParentRow(parent, childRow); } } return parent == r.Parent; }
Workaround: set up the templates from code, http://www.telerik.com/help/winforms/gridview-overview.html
To reproduce: 1. Add a RadTreeView and a RadGridView 2. Use the following code snippet. 3. Select a node from the RadtreeView. 4. Activate the editor for the new row in RadGridView. 5. While the grid editor is active, select a new node in the tree. public Form1() { InitializeComponent(); this.radGridView1.MasterTemplate.AddNewBoundRowBeforeEdit = true; } public class ClassA { public int Id { get; set; } public string Name { get; set; } public string Grade { get; set; } public ClassA() { } public ClassA(int id, string name, string grade) { this.Id = id; this.Name = name; this.Grade = grade; } } public class ClassB { public int NewID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public ClassB() { } public ClassB(int id, string firstName, string lastName) { this.NewID = id; this.FirstName = firstName; this.LastName = lastName; } } private void radTreeView1_SelectedNodeChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e) { if (radGridView1.DataSource is BindingList<ClassA>) { this.radGridView1.Columns.Clear(); this.radGridView1.DataSource = null; BindingList<ClassB> list = new BindingList<ClassB>() { new ClassB(1, "John", "Wick") }; this.radGridView1.DataSource = list; } else { this.radGridView1.DataSource = null; BindingList<ClassA> list = new BindingList<ClassA>() { new ClassA(1,"John", "A+") }; this.radGridView1.Columns.Clear(); this.radGridView1.DataSource = list; } } Workaround: this.radGridView1.MasterTemplate.AddNewBoundRowBeforeEdit = false;