To reproduce: - Select several rows and cells in excel and copy them. - Paste in the self-reference grid. - Only the first row is copied. Workaround: private void RadGridView1_Pasting(object sender, GridViewClipboardEventArgs e) { e.Cancel = true; List<List<string>> rows = this.GetTextData(); PrintGridTraverser traverser = new PrintGridTraverser(this.radGridView1.MasterView); while (traverser.Current != this.radGridView1.CurrentRow) { traverser.MoveNext(); } traverser.MovePrevious(); int rowIndex = 0; int colIndex = this.radGridView1.CurrentColumn.Index; while (traverser.MoveNext() && rowIndex < rows.Count) { for (int i = colIndex; i < this.radGridView1.Columns.Count && i - colIndex < rows[rowIndex].Count; i++) { traverser.Current.Cells[i].Value = rows[rowIndex][i - colIndex]; } rowIndex++; } }
To reproduce: - Add GridViewTextBoxColumn and set the MaxLength property. - Paste in data row while the is not in edit mode. Workaround: private void RadGridView1_Pasting(object sender, Telerik.WinControls.UI.GridViewClipboardEventArgs e) { if (radGridView1.CurrentColumn.Name == "column1") { GridViewTextBoxColumn col = new GridViewTextBoxColumn(); var lenght = col.MaxLength; if (Clipboard.ContainsData(DataFormats.Text)) { e.Cancel = true; string data = Clipboard.GetData(DataFormats.Text).ToString(); radGridView1.CurrentCell.Value = data.Substring(0, lenght); } } }
Please refer to the attached sample project and gif files. The user is not allowed to drop in the first half of the row element. However, the drop operation is allowed in the second half. Once the RadDragOverEventArgs.CanDrop property is set to false, the before/after row hint is disposed and it is not shown for this row anymore. Workaround: public class CustomRadGridViewDragDropService : RadGridViewDragDropService { public CustomRadGridViewDragDropService(RadGridViewElement gridViewElement) : base(gridViewElement) { } public override string Name { get { return typeof(RadGridViewDragDropService).Name; } } protected override void OnPreviewDragOver(RadDragOverEventArgs e) { base.OnPreviewDragOver(e); SetDragDropBehavior(); Point p = this.GridViewElement.ElementTree.Control.PointToClient(Cursor.Position); UpdateDragHintLocation(p); } } this.radGridView1.GridViewElement.RegisterService(new CustomRadGridViewDragDropService(this.radGridView1.GridViewElement));
To reproduce: populate the grid with data and use the code snippet below: public Form1() { InitializeComponent(); this.radGridView1.EnablePaging = true; this.radGridView1.AddNewRowPosition = Telerik.WinControls.UI.SystemRowPosition.Bottom; } Select the third page and click the new row at the bottom. The editor is activated as expected but the first page is made current. Workaround: use the CellEditorInitialized event and move to the desired page private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { if (e.Row is GridViewNewRowInfo) { this.radGridView1.MasterTemplate.MoveToPage(2); } }
Note: if you change the image in Windows8 theme for example, the image is successfully applied. Workaround: set the CurrentRowHeaderImage property at run time.
Workaround: create a custom RadListFilterPopup private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e) { e.FilterPopup = new MyRadListFilterPopup(e.Column); } public class MyRadListFilterPopup : RadListFilterPopup { public MyRadListFilterPopup(GridViewDataColumn dataColumn) : base(dataColumn, false) { } protected override RadListFilterDistinctValuesTable GetDistinctValuesTable() { if (this.DataColumn.OwnerTemplate.HierarchyLevel == 0) { return base.GetDistinctValuesTable(); } GridViewColumnValuesCollection distinctValues = this.GetDistinctValuesWithFilter(this.DataColumn); RadListFilterDistinctValuesTable valuesTable = new RadListFilterDistinctValuesTable(); valuesTable.FormatString = this.DataColumn.FormatString; valuesTable.DataConversionInfoProvider = this.DataColumn; GridViewComboBoxColumn comboBoxColumn = this.DataColumn as GridViewComboBoxColumn; if (comboBoxColumn != null && !String.IsNullOrEmpty(comboBoxColumn.ValueMember)) { foreach (object value in distinctValues) { if (value != null && value != System.DBNull.Value) { object rowValue = value; object lookupValue = ((GridViewComboBoxColumn)this.DataColumn).GetLookupValue(value); if (comboBoxColumn.FilteringMode == GridViewFilteringMode.DisplayMember) { rowValue = lookupValue; } if (lookupValue != null) { valuesTable.Add(lookupValue.ToString(), rowValue); } } } } else { foreach (object value in distinctValues) { valuesTable.Add(value); } } return valuesTable; } private GridViewColumnValuesCollection GetDistinctValuesWithFilter(GridViewDataColumn column) { GridViewColumnValuesCollection distinctValues = new GridViewColumnValuesCollection(); int count = column.OwnerTemplate.ExcelFilteredColumns.Count; if ((count > 0 && column == column.OwnerTemplate.ExcelFilteredColumns[count - 1]) || column.OwnerTemplate.HierarchyLevel > 0) { if (count == 1 || column.OwnerTemplate.HierarchyLevel > 0) { int index = column.Index; if (index >= 0) { IList<GridViewRowInfo> templateRows = column.OwnerTemplate.Rows; if (templateRows.Count == 0 && column.OwnerTemplate.Parent != null && column.OwnerTemplate.HierarchyLevel > 0) { templateRows = new List<GridViewRowInfo>(); GridViewInfo templateViewInfo = column.OwnerTemplate.MasterViewInfo; for (int i = 0; i < column.OwnerTemplate.Parent.Rows.Count; i++) { GridViewRowInfo parentRow = column.OwnerTemplate.Parent.Rows[i]; ((List<GridViewRowInfo>)templateRows).AddRange(column.OwnerTemplate.HierarchyDataProvider.GetChildRows(parentRow, templateViewInfo)); } } foreach (GridViewRowInfo row in templateRows) { object cellValue = row.Cells[index].Value; if (!distinctValues.Contains(cellValue)) { distinctValues.Add(cellValue); } } if (distinctValues.Count > 0) { return distinctValues; } } } } return distinctValues; } }
Workaround: create a custom GridDetailViewCellElement Public Class Form1 Sub New() InitializeComponent() AddHandler dgvPatients.CreateCell, AddressOf dgvPatients_CreateCell End Sub Private Sub dgvPatients_CreateCell(sender As Object, e As GridViewCreateCellEventArgs) If e.CellType = GetType(GridDetailViewCellElement) Then e.CellElement = New MyGridDetailViewCellElement(e.Column, e.Row) End If End Sub End Class Public Class MyGridDetailViewCellElement Inherits GridDetailViewCellElement Sub New(column As GridViewColumn, rowElement As GridRowElement) MyBase.New(column, rowElement) End Sub Public Overrides Sub UpdateTabItemsVisibility() If Me.DetailsRow Is Nothing Then Return End If MyBase.UpdateTabItemsVisibility() End Sub End Class
To reproduce: populate a grid and enable multiple selection. Use cell selection. When you click the row header, the entire row (all cells from the row) is selected no matter the SelectionMode. However, if you start a selection from the row header and move the cursor, only the cells from the first column get selected. The attached gif file illustrates the behavior. The expected behavior is that all cells from the affected columns should be selected when starting the selection from the row header. Workaround: Sub New() InitializeComponent() Me.RadGridView1.MultiSelect = True Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect AddHandler Me.RadGridView1.MouseDown, AddressOf GridMouseDown AddHandler Me.RadGridView1.MouseUp, AddressOf GridMouseUp AddHandler Me.RadGridView1.MouseMove, AddressOf GridMouseMove End Sub Dim isMouseDown = False Dim startRow As GridViewRowInfo Dim lastHoveredCell As GridCellElement Private Sub GridMouseDown(sender As Object, e As MouseEventArgs) Dim cell As GridRowHeaderCellElement = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridRowHeaderCellElement) If cell IsNot Nothing Then isMouseDown = True startRow = cell.RowInfo End If End Sub Private Sub GridMouseUp(sender As Object, e As MouseEventArgs) isMouseDown = False startRow = Nothing End Sub Private Sub GridMouseMove(sender As Object, e As MouseEventArgs) If isMouseDown Then Dim cellUnderMouse As GridCellElement = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridCellElement) If cellUnderMouse IsNot Nothing AndAlso Not cellUnderMouse.Equals(lastHoveredCell) Then lastHoveredCell = cellUnderMouse Me.RadGridView1.ClearSelection() Me.RadGridView1.SelectedCells.BeginUpdate() If startRow.Index > cellUnderMouse.RowInfo.Index Then For index = cellUnderMouse.RowInfo.Index To startRow.Index Me.RadGridView1.Rows(index).IsSelected = True Next Else For index = startRow.Index To cellUnderMouse.RowInfo.Index For Each cell As GridViewCellInfo In Me.RadGridView1.Rows(index).Cells cell.IsSelected = True Next Next End If Me.RadGridView1.SelectedCells.EndUpdate(True) End If End If End Sub
The behavior should be consistent no matter if you change the current column or the current row.
Please refer to the attached sample project which result is illustrated in the provided screenshot. Workaround: this.radGridView1.ClearSelection(); this.radGridView1.CurrentRow = null; this.radGridView1.Rows[1].Cells[2].IsSelected = true;
Please refer to the attached sample project and select a new value in the drop down. Workaround: change the PageSize in the RadDropDownListElement.PopupClosed event: public sealed class PageSizeDropdownHeaderCellElement : GridHeaderCellElement { public PageSizeDropdownHeaderCellElement(GridViewColumn col, GridRowElement row) : base(col, row) { TextAlignment = ContentAlignment.TopCenter; Alignment = ContentAlignment.TopCenter; } private RadDropDownListElement _dropDownListElement; protected override void CreateChildElements() { base.CreateChildElements(); _dropDownListElement = new RadDropDownListElement(); if (_dropDownListElement != null && _dropDownListElement.DataSource == null) { _dropDownListElement = new RadDropDownListElement(); _dropDownListElement.BindingContext = new BindingContext(); _dropDownListElement.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList; _dropDownListElement.Items.Clear(); _dropDownListElement.Items.Add(new RadListDataItem("10", 10) { Selected = true }); _dropDownListElement.Items.Add(new RadListDataItem("25", 25)); _dropDownListElement.Items.Add(new RadListDataItem("50", 50)); _dropDownListElement.Items.Add(new RadListDataItem("100", 100)); _dropDownListElement.Items.Add(new RadListDataItem("All", -1)); _dropDownListElement.Margin = new Padding(15, 0, 0, 0); _dropDownListElement.StretchHorizontally = true; _dropDownListElement.NotifyParentOnMouseInput = false; _dropDownListElement.Popup.MouseClick += Popup_MouseClick; _dropDownListElement.PopupClosed += _dropDownListElement_PopupClosed; this.Children.Add(_dropDownListElement); } } RadListVisualItem elementUnderMouse; private void Popup_MouseClick(object sender, MouseEventArgs e) { elementUnderMouse = _dropDownListElement.Popup.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem; } private void _dropDownListElement_PopupClosed(object sender, RadPopupClosedEventArgs args) { if (elementUnderMouse == null) { return; } if (_dropDownListElement.SelectedIndex == -1) return; var pageSize = Convert.ToInt32(elementUnderMouse.Data.Value); if (pageSize == -1) { pageSize = GridControl.RowCount; } else { pageSize = pageSize <= GridControl.RowCount ? pageSize : GridControl.RowCount; } this.RowInfo.Tag = pageSize; GridControl.PageSize = pageSize; elementUnderMouse = null; } protected override void SetContentCore(object value) { if (_dropDownListElement != null && this.RowInfo.Tag != null) { this._dropDownListElement.SelectedValue = (int)this.RowInfo.Tag; } } public override bool IsCompatible(GridViewColumn data, object context) { return data is ActionColumn && context is GridTableHeaderRowElement; } protected override Type ThemeEffectiveType { get { return typeof(GridHeaderCellElement); } } }
To reproduce: GridViewTextBoxColumn textBoxColumn1 = new GridViewTextBoxColumn("Col 1"); textBoxColumn1.FieldName = "col1"; radGridView1.MasterTemplate.Columns.Add(textBoxColumn1); GridViewTextBoxColumn textBoxColumn2 = new GridViewTextBoxColumn("Col 2"); textBoxColumn2.FieldName = "col2"; textBoxColumn2.FormatString = "{0:d}"; radGridView1.MasterTemplate.Columns.Add(textBoxColumn2); radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; DataTable dt = new DataTable(); dt.Columns.Add("col1", typeof(string)); dt.Columns.Add("col2", typeof(DateTime)); for (int i = 0; i < 10; i++) { dt.Rows.Add("Item" + i, DateTime.Now.AddDays(i)); } this.radGridView1.AutoGenerateColumns = false; this.radGridView1.DataSource = dt; Right click the row header cell and select Copy. The following exception occurs although we don't have a GridViewDateTimeColumn : System.InvalidCastException was unhandled HResult=-2147467262 Message=Unable to cast object of type 'Telerik.WinControls.UI.GridViewTextBoxColumn' to type 'Telerik.WinControls.UI.GridViewDateTimeColumn'. Source=Telerik.WinControls.GridView StackTrace: at Telerik.WinControls.UI.MasterGridViewTemplate.CopyRows(String format, Boolean cut, Boolean cutOperation, StringBuilder content) at Telerik.WinControls.UI.MasterGridViewTemplate.ProcessContent(String format, Boolean cut, Boolean cutOperation) at Telerik.WinControls.UI.MasterGridViewTemplate.CopyContent(Boolean cut) at Telerik.WinControls.UI.MasterGridViewTemplate.Copy() at Telerik.WinControls.UI.GridDataRowElement.copyItem_Click(Object sender, EventArgs e) at Telerik.WinControls.RadElement.OnClick(EventArgs e) at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e) at Telerik.WinControls.UI.RadMenuItem.OnClick(EventArgs e) at Telerik.WinControls.RadElement.DoClick(EventArgs e) at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e) at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e) at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at Telerik.WinControls.RadControl.WndProc(Message& m) at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at _1075342CopyText.Program.Main() in d:\Projects\1075342CopyText_Binding\Program.cs:line 17 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: Workaround: use a GridViewDateTimeColumn
Please refer to the attached gif file illustrating how to reproduce the error with the Demo application. Workaround: this.radGridView1.UseScrollbarsInHierarchy = true;
To reproduce: public RadForm1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("Name"); for (int i = 0; i < 50; i++) { dt.Rows.Add(i, "Data" + i); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.AutoSizeRows = false; } private void RadForm1_Load(object sender, EventArgs e) { this.radGridView1.Rows[5].MinHeight = 80; this.radGridView1.Rows[5].MaxHeight = 100; } The Min/MaxHeight is not respected even when resizing the row. Workaround: set the Height property.
To reproduce: - Subscribe to the CellClick event - Click several times in the grid with the right mouse button. - At some point, the CellClick event will be executed. Workaround: - Use the Click event: private void RadGridView1_Click(object sender, EventArgs e) { var args = e as MouseEventArgs; if (args.Button == MouseButtons.Left) { var clickedCell = radGridView1.ElementTree.GetElementAtPoint(args.Location) as GridDataCellElement; if (clickedCell != null) { //add your code here } } }
Use attached project to reproduce. The video shows what steps you need to take. Workaround: Use CellEndEdit instead.
Use the attached project to reproduce. The video shows what steps you need to take.
To reproduce: private void Form2_Load(object sender, EventArgs e) { this.productsTableAdapter.Fill(this.nwindDataSet.Products); this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories); this.radGridView1.AutoGenerateHierarchy = true; this.radGridView1.DataSource = this.nwindDataSet; this.radGridView1.DataMember = "Categories"; this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.MasterTemplate.Templates.First().AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewSummaryItem summaryItem = new GridViewSummaryItem(); summaryItem.Name = "CategoryID"; summaryItem.Aggregate = GridAggregateFunction.Count; GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(); summaryRowItem.Add(summaryItem); this.radGridView1.SummaryRowsTop.Add(summaryRowItem); GridViewSummaryItem summaryItem2 = new GridViewSummaryItem(); summaryItem2.Name = "UnitPrice"; summaryItem2.Aggregate = GridAggregateFunction.Sum; GridViewSummaryRowItem summaryRowItem2 = new GridViewSummaryRowItem(); summaryRowItem2.Add(summaryItem2); this.radGridView1.MasterTemplate.Templates.First().SummaryRowsTop.Add(summaryRowItem2); } private void SetNumberFormat() { this.radGridView1.Columns["CategoryID"].FormatString = "{0:F4}"; this.radGridView1.SummaryRowsTop[0][0].FormatString = "{0:F4}"; this.radGridView1.MasterTemplate.Templates.First().Columns["UnitPrice"].FormatString = "{0:F4}"; this.radGridView1.MasterTemplate.Templates.First().SummaryRowsTop[0][0].FormatString = "{0:F4}"; } private void radButton1_Click(object sender, EventArgs e) { SetNumberFormat(); } Workaround: Clear and add back the summary rows when a value in the child template is changed. private void radButton1_Click(object sender, EventArgs e) { this.radGridView1.MasterTemplate.Templates.First().SummaryRowsTop.Clear(); GridViewSummaryItem summaryItem2 = new GridViewSummaryItem(); summaryItem2.Name = "UnitPrice"; summaryItem2.Aggregate = GridAggregateFunction.Sum; GridViewSummaryRowItem summaryRowItem2 = new GridViewSummaryRowItem(); summaryRowItem2.Add(summaryItem2); this.radGridView1.MasterTemplate.Templates.First().SummaryRowsTop.Add(summaryRowItem2); SetNumberFormat(); }
To reproduce: - Add one-to-many relations hierarchy 3 or more child templates. - Export the grid using GridViewSpreadExport - The child rows of the last parent row are missing. Workaround: Add an empty parent row at the end of the grid.
To reproduce: Sub New() InitializeComponent() Dim dt As New DataTable() dt.Columns.Add("Price", GetType(System.Double)) dt.Columns.Add("Name", GetType(System.String)) dt.Columns.Add("Nr", GetType(System.Double)) For i As Integer = 0 To 49 dt.Rows.Add(i, "Data" & i, i) Next With Me.RadGridView1 .DataSource = dt .Columns("Price").FormatString = "{0:C2}" .Columns("Nr").FormatString = "{0:N1}" .Columns("Price").ExcelExportType = Export.DisplayFormatType.Currency ' .AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill End With Me.RadGridView1.Columns("Price").ExcelExportType = Export.DisplayFormatType.Currency Me.RadGridView1.Columns("Nr").ExcelExportType = Export.DisplayFormatType.Custom Me.RadGridView1.Columns("Nr").ExcelExportFormatString = "{0:N1}" Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim spreadStreamExport As New GridViewSpreadStreamExport(Me.RadGridView1) spreadStreamExport.ExportVisualSettings = True Dim fileName As String = "..\..\" + DateTime.Now.ToLongTimeString().Replace(":", "_").ToString() + ".xlsx" spreadStreamExport.RunExport(fileName, New SpreadStreamExportRenderer()) Process.Start(fileName) End Sub Workaround: Me.RadGridView1.Columns("Nr").ExcelExportType = Export.DisplayFormatType.Fixed AddHandler spreadStreamExport.CellFormatting, AddressOf CellFormatting Private Sub CellFormatting(sender As Object, e As SpreadStreamCellFormattingEventArgs) If e.ExportCell.ColumnIndex = 2 Then e.ExportCell.ExportFormat = "0.0" End If End Sub