The following article shows how to attach the source code to your project:
https://docs.telerik.com/devtools/winforms/knowledge-base/attach-telerik-source-code-to-your-project
When attaching the .NETCore projects (latest version R1 2023) to your application, the project can't be built.
An exception occurs when trying to export the RadGridView using the ExportToPDF class with the following message.
System.SystemException: 'System.MethodAccessException: Attempt by security transparent method 'Telerik.Pdf.Gdi.GdiFontEnumerator.get_FamilyNames()' to call native code through method 'Telerik.WinControls.NativeMethods.EnumFontFamiliesEx(IntPtr, LOGFONT, FontEnumDelegate, Int32, Int32)' failed. Methods must be security critical or security safe-critical to call native code.
at Telerik.Pdf.Gdi.GdiFontEnumerator.get_FamilyNames()
at Telerik.Apoc.Pdf.FontSetup.AddSystemFonts(FontType fontType)
at Telerik.Apoc.Render.Pdf.PdfRenderer.SetupFontInfo(FontInfo fontInfo)
at Telerik.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)'
This exception is observed only when the referenced DLLs target the .Net Framework 4.8 version.
Steps to reproduce:
1. Bind the grid and enable the search row
2. Enter some search text
3. Delete records from the applied DataSource collection. It may be necessary to perform the delete operation several times before the error occurs.
The error can be reproduced with the following code snippet:
Dim dt As New DataTable
Sub New()
InitializeComponent()
dt.Columns.Add("Id", GetType(Integer))
dt.Columns.Add("Name", GetType(String))
For index = 1 To 10000
dt.Rows.Add(index, Guid.NewGuid.ToString())
Next
Me.RadGridView1.DataSource = dt
Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
Me.RadGridView1.AllowSearchRow = True
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
For index = 1 To 50
dt.Rows.RemoveAt(0)
Next
End Sub
There is a sample project attached as well and its result is illustrated in the gif file.
Stack trace:
at Telerik.WinControls.UI.MasterGridViewTemplate.set_CurrentRow(GridViewRowInfo value) at Telerik.WinControls.UI.RadGridView.set_CurrentRow(GridViewRowInfo value) at Telerik.WinControls.UI.GridViewSearchRowInfo.SetCurrent(GridSearchResultCellInfo cell) at Telerik.WinControls.UI.GridViewSearchRowInfo.SetCurrent(GridSearchResultCellInfo cell, Boolean checkInvokeRequired) at Telerik.WinControls.UI.GridViewSearchRowInfo.SelectNextSearchResult() at Telerik.WinControls.UI.GridViewSearchRowInfo.Search(String criteria) at Telerik.WinControls.UI.GridViewSearchRowInfo.Telerik.WinControls.UI.IGridViewEventListener.PostProcessEvent(GridViewEvent eventData) at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode) at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent) at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents() at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent) at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI) at Telerik.WinControls.UI.GridViewRowCollection.DispatchDataViewChangedEvent(DataViewChangedEventArgs args, GridEventType type) at Telerik.WinControls.UI.GridViewRowCollection.ListSource_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) at Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) at Telerik.WinControls.Data.RadListSource`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at Telerik.WinControls.Data.RadListSource`1.RemoveItem(Int32 index) at Telerik.WinControls.Data.RadListSource`1.currencyManager_ListChanged(Object sender, ListChangedEventArgs e) at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e) at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e) at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e) at System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e) at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e) at System.ComponentModel.BindingList`1.FireListChanged(ListChangedType type, Int32 index) at System.ComponentModel.BindingList`1.RemoveItem(Int32 index) at System.Collections.ObjectModel.Collection`1.Remove(T item) at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Remove(Object value) at System.Windows.Forms.BindingSource.Remove(Object value)
When you use var, object is assumed. Of course, the object contains a GridViewCellInfo, but you have to cast it first to use one of its members.
The goal is to prevent unnecessary casts.
ArgumentOutOfRangeException is thrown when the control is auto-sized (AutoSize = true) and we try to select all (MultiSelect = true with CellSelect) rows by clicking and moving the mouse.
As a workaround, we could set the MaximumSize property of the RadGridView.
this.radGridView1.MaximumSize = new Size(1000,1000);
Run the attached sample project on a monitor with 100% DPI scaling. Then, try moving the form to the second monitor with 150% DPI scaling. You will notice that the following error occurs:
Workaround: instead of using a RadTextBoxControlElement in the custom cell, feel free to use a RadTextBoxElement. However, please have in mind that RadTextBoxElement hosts the MS TextBox and using controls in grid cells may slow down the scrolling and will cause visual glitches as they do not support clipping.
When the columns are auto-generated, the way to modify the columns is to use the Columns collection. We could expose an event that will be called when the columns are auto-generating. From the event arguments, we could get the newly created column and replace with if needed or modify it. Similar to the CreateRow event of the control.
Steps to reproduce:
1. Run the sample project and select a row inside the grid
2. Press Ctrl+B
The following error occur:
Workaround: set the EnableFastScrolling property to false.
Run the attached project and click List then Export.
Expected:
Actual:
Workaround:
Private Sub RadButton2_Click(sender As Object, e As EventArgs) Handles RadButton2.Click
Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(gvAssetSchedule)
AddHandler spreadExporter.CellFormatting, AddressOf spreadExporter_CellFormatting
Dim exportRenderer As New SpreadExportRenderer()
spreadExporter.ExportVisualSettings = True
Dim filename = "..\..\export" & DateTime.Now.ToLongTimeString().Replace(":", "_") & ".xlsx"
spreadExporter.RunExport(filename, exportRenderer)
Process.Start(filename)
End Sub
Private Sub spreadExporter_CellFormatting(sender As Object, e As Telerik.WinControls.Export.CellFormattingEventArgs)
If e.GridCellInfo Is Nothing Then
Dim selection As CellSelection = e.CellSelection
Dim range As CellRange = selection.CellRanges(0)
Dim val = selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).GetValue()
Dim format As New CellValueFormat("@")
selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).SetFormat(format)
Dim dt As New DateTime(1900, 1, 1)
Dim parsedDays = 0
If Integer.TryParse(val.Value.RawValue, parsedDays) Then
dt = dt.AddDays(parsedDays)
selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).SetValue(dt.Year & "-" & MonthName(dt.Month))
End If
End If
End Sub
Use the following code:
public RadForm1()
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add("Id");
dt.Columns.Add("Name");
for (int i = 0; i < 10; i++)
{
dt.Rows.Add(i, "Item" + i);
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.CellValidating += radGridView1_CellValidating;
}
private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e)
{
if (e.Column.Index == 0 && e.ActiveEditor != null && e.Value + "" == "1")
{
e.Cancel = true;
RadMessageBox.Show("IncorrectValue");
}
}
Follow the steps:
1. Scroll to the last row.
2. Enter value "1" in the first cell of the last row
3. Click the area above the scrollbar's thumb to trigger scrolling to the top. You will notice that the message box will be shown and the view will be scrolled. Once the message is closed, the error occurs.
Workaround:
public class CustomGridView : RadGridView
{
public override string ThemeClassName
{
get
{
return typeof(RadGridView).FullName;
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
RadScrollBarElement scrollbar= this.GridViewElement.ElementTree.GetElementAtPoint ( e.Location) as RadScrollBarElement;
if (scrollbar!=null && this.IsInEditMode)
{
this.EditorManager.CloseEditorWhenValidationFails = false;
this.EditorManager.CloseEditor();
return;
}
base.OnMouseDown(e);
}
}
Please refer to the below gif file. You will notice that the drop row line is shown only when dropping in the same grip but not when dropping on another grid:
Workaround: use the project in the following forum post: https://www.telerik.com/forums/preview-drop---drag-drop-between-gridview#5477699
ComboBox column DataSource property is not visible in the Designer MS Property Builder when the previously selected node was RadGridView.