Steps to reproduce:
1. Bind the grid to BindingList
2. Call BestFitColumns method in form's constructor
3. Use Fluent/Crystal theme
4. Rebind the grid by setting DataSource=null
5. Exception is thrown
Stack trace:
en Telerik.WinControls.UI.BestFitHelper.SetColumnWidth(GridViewColumn column, Single desiredWidth) en Telerik.WinControls.UI.BestFitHelper.BestFitColumnCore(GridViewColumn column, BestFitColumnMode mode) en Telerik.WinControls.UI.BestFitHelper.ProcessRequests() en Telerik.WinControls.UI.GridTableElement.UpdateAll() en Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args) en Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args) en Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData) en Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData) en Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode) en Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent) en Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent) en Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents() en Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent) en Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI) en Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(GridViewEvent gridEvent, Boolean postUI) en Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(Object sender, DataViewChangedEventArgs args) en Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e) en Telerik.WinControls.UI.MasterGridViewTemplate.OnViewChanged(Object sender, DataViewChangedEventArgs e) en Telerik.WinControls.UI.GridViewTemplate.CollectionView_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) en Telerik.WinControls.Data.RadCollectionView`1.OnCollectionChanged(NotifyCollectionChangedEventArgs args) en Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify) en Telerik.WinControls.Data.RadDataView`1.RefreshOverride() en Telerik.WinControls.Data.RadDataView`1.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args) en Telerik.WinControls.Data.RadCollectionView`1.source_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) en Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) en Telerik.WinControls.Data.RadListSource`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) en Telerik.WinControls.Data.RadListSource`1.EndUpdate(Boolean notifyUpdates) en Telerik.WinControls.Data.RadListSource`1.Initialize() en Telerik.WinControls.Data.RadListSource`1.Bind(Object dataSource, String dataMember) en Telerik.WinControls.Data.RadListSource`1.set_DataSource(Object value) en Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value) en Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
To reproduce: add a RadGridView with several columns. Set the Enabled property to false. Try to open the Property Builder and you will notice that the Columns are disabled in it. Workaround: set the Enabled property to false at run time. Thus, it would be possible to manipulate the columns via the Property Builder at design time.
To reproduce: Please run the sample project and follow the steps from the gif file. Workaround: private void radGridView1_SizeChanged(object sender, EventArgs e) { this.radGridView1.MasterTemplate.Refresh(); } public class Grid : RadGridView { public override string ThemeClassName { get { return typeof(RadGridView).FullName; } } protected override void OnResize(EventArgs e) { object value = null; if (this.ActiveEditor != null) { value = this.ActiveEditor.Value; } base.OnResize(e); if (value != null && this.CurrentCell != null) { this.CurrentCell.Value = value; } } }
To reproduce: please refer to the attached sample project. Note that the CellValidating event is fired twice even without showing a RadMessageBox. With an MS Button the problem is not reproducible. Workaround: use the RadGridView.ValueChanging event to perform validation while the user is typing in the active editor: private void radGridView1_ValueChanging(object sender, Telerik.WinControls.UI.ValueChangingEventArgs e) { if (((string)e.NewValue) != "x") { RadMessageBox.Show("Only 'x' allowed!"); e.Cancel = true; } }
I have a radGridView with MutliSelect set to true and SelectionMode set to FullRowSelect. A theme is applied, and this behavior is seen with other themes too. Several columns are pinned to the left.
When I multi-select rows using the shift or control buttons by clicking one of the cells under the frozen columns, the row is selected and colored accordingly, except for the cell that was actually clicked which remains with the unselected color.
If I multi-select by clicking on one of the cells under an unpinned column, the full row is selected as expected.
In the image below, I held down shift and selected the first and third row in sequence under the Officer column.
How can I fix this to show the complete row selected?
To reproduce: ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition(); view.ColumnGroups.Add(new GridViewColumnGroup("Customer Contact")); view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow()); view.ColumnGroups[0].Rows[0].ColumnNames.Add("Address"); view.ColumnGroups[0].Rows[0].ColumnNames.Add("Contact"); radGridView1.Columns.Add("Address"); radGridView1.Columns.Add("Contact"); radGridView1.Columns[0].Width = 300; radGridView1.Columns[1].Width = 300; radGridView1.ViewDefinition = view; for (int i = 0; i < 10; i++) { radGridView1.Rows.Add("test test test test test", "test"); } Workaround: docs.telerik.com/devtools/winforms/telerik-presentation-framework/export-renderers/spreadexportrenderer
When Excel-like filtering is enabled and the user selects an item from the "Available Filters" drop down menu, a CompositeFilterForm is shown.
C#. net core 6, winforms application, TekerikNuGet3 package source, UI.for.WinForms.AllControls.NetCore package 2022.2.622
I am trying to export selected cells from a RadGridView as a csv file.
When using "var exporter = new ExportToCSV(Dgv)" then "exporter.RunExport(fileName);" writes the csv file correctly. It exports every cell.
It doesn't support exporting selections so I wrote a function to do this . The one below is what I used in my project to test what I was doing. It initially writes the csv to a worksheet and wrote that using formatprovider to file, then I just created a stringbuilder adding quotes and appended that to the file afterwards.
Writing the worksheet, the csv values haven't been quoted, plus number fields have had leading zeros removed which proves to be a problem when telephone numbers are stored in a field.
So I googled and found the Settings property which is there to set csv options. But they are private, not public therefore I can't set up the csv propertly.
private void radButton1_Click(object sender, EventArgs e)
{
var workbook = new Workbook();
var worksheet = workbook.Worksheets.Add();
var rowIndex = 0;
var columnIndex = -1;
var sb = new StringBuilder();
var prevColumnIndex = -1;
// ForEach cell are accessed vertically then horizontally.
foreach (var cell in Dgv.SelectedCells)
{
// Cell is included in selection even if it's invisible
// so check visibility and ignore if it isnt
if (!cell.ColumnInfo.IsVisible) continue;
// At bottom of column, rownum will change. Watch for this
// and reset x and y values
var rowNum = cell.RowInfo.Index;
if (rowNum != prevColumnIndex)
{
prevColumnIndex = rowNum;
rowIndex = 0;
columnIndex++;
sb.AppendLine("");
}
else if (!string.IsNullOrEmpty(sb.ToString()))
sb.Append(",");
var value = cell.Value;
worksheet.Cells[columnIndex, rowIndex++ ].SetValue(value.ToString());
sb.Append($"\"{value.ToString()}\"");
}
var fileName = @"C:\temp\SampleFile.csv";
IWorkbookFormatProvider formatProvider = new CsvFormatProvider();
using var output = new FileStream(fileName, FileMode.Create);
formatProvider.Export(workbook, output);
output.Close();
// Write contents of sb to the file for comparison sake
File.AppendAllText(fileName, sb.ToString());
}
i am getting a null reference exception with the following call stack:
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
at Telerik.WinControls.UI.TableViewRowLayoutBase.GetRowHeight(Telerik.WinControls.UI.GridViewRowInfo)
at Telerik.WinControls.UI.RowElementProvider.GetElementSize(Telerik.WinControls.UI.GridViewRowInfo)
at Telerik.WinControls.UI.ItemScroller`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetScrollHeight(System.__Canon)
at Telerik.WinControls.UI.ItemScroller`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].ScrollDown(Int32)
at Telerik.WinControls.UI.ItemScroller`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].ScrollTo(Int32)
at Telerik.WinControls.UI.ItemScroller`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].scrollbar_ValueChanged(System.Object, System.EventArgs)
at Telerik.WinControls.UI.RadScrollBarElement.OnValueChanged(Int32, Int32)
at Telerik.WinControls.UI.RadScrollBarElement.set_Value(Int32)
at Telerik.WinControls.UI.ItemScroller`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].UpdateScrollValue()
at Telerik.WinControls.UI.ItemScroller`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].UpdateScrollRange()
at Telerik.WinControls.UI.RowScroller.UpdateScrollRange()
at Telerik.WinControls.UI.GridTableElement.UpdateNoDataText()
at Telerik.WinControls.UI.GridTableElement.UpdateAll()
at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(System.Object, Telerik.WinControls.UI.DataViewChangedEventArgs)
at Telerik.WinControls.UI.GridTableElement.UpdateView(System.Object, Telerik.WinControls.UI.DataViewChangedEventArgs)
at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(Telerik.WinControls.UI.GridViewEvent)
at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(Telerik.WinControls.UI.GridViewEvent)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(Telerik.WinControls.UI.GridViewEvent, Telerik.WinControls.UI.PriorityWeakReferenceList, Telerik.WinControls.UI.GridEventProcessMode)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(Telerik.WinControls.UI.GridViewEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(Telerik.WinControls.UI.GridViewEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(Telerik.WinControls.UI.GridViewEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(Telerik.WinControls.UI.GridViewTemplate, Telerik.WinControls.UI.GridViewEvent, Boolean)
at Telerik.WinControls.UI.GridViewTemplate.DispatchEvent(Telerik.WinControls.UI.GridViewEvent, Boolean)
at Telerik.WinControls.UI.GridViewTemplate.DispatchDataViewChangedEvent(System.Object, Telerik.WinControls.UI.DataViewChangedEventArgs)
at Telerik.WinControls.UI.GridViewTemplate.OnViewChanged(System.Object, Telerik.WinControls.UI.DataViewChangedEventArgs)
at Telerik.WinControls.UI.MasterGridViewTemplate.OnViewChanged(System.Object, Telerik.WinControls.UI.DataViewChangedEventArgs)
at Telerik.WinControls.UI.GridViewTemplate.EndUpdate(Boolean, Telerik.WinControls.UI.DataViewChangedEventArgs)
at Telerik.WinControls.UI.MasterGridViewTemplate.EndUpdate(Boolean, Telerik.WinControls.UI.DataViewChangedEventArgs)
at Telerik.WinControls.UI.GridViewTemplate.set_RowCount(Int32)
at Telerik.WinControls.UI.RadGridView.set_RowCount(Int32)
at Communication_Logger.frmCommunicationLogger.RadRibbonForm1_OnDataReceived(Communication_Logger.Data)
at Communication_Logger.ChannelClass.Serial_DataReceived(System.Object, System.IO.Ports.SerialDataReceivedEventArgs)
at System.IO.Ports.SerialPort.CatchReceivedEvents(System.Object, System.IO.Ports.SerialDataReceivedEventArgs)
at System.IO.Ports.SerialStream+EventLoopRunner.CallReceiveEvents(System.Object)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
the setup is a dotNet 4.5.2 winforms application with RadGridView in virtual mode.
The exception occur when the application is left working for days (2 in this case) without any user interaction.
The application normally updates a list that is used by the gridview, the list records are added and removed continuously, the grid view RowCount is updated via a timer.
i suspect that the RowCount reported at one point in time doesn't match the list size as it is trimmed, and therfore the GetRowHeight fails as the data doesn't exist - can this be handled in the gridview - to avoid a termination of the process due to the exception ?
regards,
guy.
RadGridview 1.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.HeaderCells)