To reproduce: run the attached sample project and click the 'export' button. The exported file fill be automatically opened. If you select several cells from the UnitPrice column you will see at the bottom that the cell values ' total is displayed. However, if you include the summary item's value in the selection its value is not taken into consideration. If you pay attention to the cell's format, it will be General instead of custom numeric one.
Workaround:
Private Sub spreadExporter_CellFormatting(sender As Object, e As Telerik.WinControls.Export.CellFormattingEventArgs)
If e.GridRowInfoType = GetType(GridViewSummaryRowInfo) AndAlso e.GridCellInfo.ColumnInfo.Name = "DecimalColumn" Then
Dim cellSelection As CellSelection = TryCast(e.CellSelection, CellSelection)
Dim cellFormat As New CellValueFormat("### ### ###.00")
If cellFormat IsNot Nothing Then
cellSelection.SetValue(Decimal.Parse(cellSelection.GetValue().Value.RawValue.Replace(" ", "")))
cellSelection.SetFormat(cellFormat)
End If
End If
End Sub
To reproduce:
private void radButton1_Click(object sender, EventArgs e)
{
radGridView1.MasterView.TableSearchRow.SelectNextSearchResult();
}
Check the index in the search textbox, it is not updated.
Workaround:
var cell = radGridView1.TableElement.FindDescendant<GridSearchCellElement>();
if (cell != null)
{
cell.FindNextButton.PerformClick();
}
To reproduce:
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("NumberAsShort", typeof(ushort));
for (int i = 0; i < 100; i++)
{
dt.Rows.Add(i, "Row" + i, i );
}
this.radGridView1.DataSource = dt;
Workaround: use the CellFormatting event https://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells
To reproduce, perform the following steps with the attached project:
Step 1: Create Sample Database
==============================
New (Sample1.db)
Import
Save
Close
Step 2:
======
Open (Sample1.db)
Import
Save
Close
Step 3:
======
New (Sample2.db)
Import (Exception)
Workaround:
radGridView1.GridViewElement.Navigator = new MyNavigator();
class MyNavigator : BaseGridNavigator
{
public override bool SelectLastRow()
{
var enumerator = typeof(BaseGridNavigator).GetField("enumerator", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this) as GridTraverser;
enumerator.Reset();
return base.SelectLastRow();
}
}
Use attached to reproduce. Workaround: Use CellFormatting instead of RowFormating.
Workaround: adjust the cell/row spacing
this.radGridView1.TableElement.CellSpacing = -2;
this.radGridView1.TableElement.RowSpacing = -2;
To reproduce: run the attached sample project and press the "stream export" button.
Workaround: use the GridViewSpreadExport https://docs.telerik.com/devtools/winforms/gridview/exporting-data/spread-export
Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(RadGridView1)
Dim exportRenderer As New SpreadExportRenderer()
Dim fileName As String = "..\..\Export" & DateTime.Now.ToLongTimeString().Replace(":", "_") + ".xlsx"
spreadExporter.RunExport(fileName, exportRenderer)
Workaround:
private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
GridDataCellElement cell = e.CellElement as GridDataCellElement ;
if (cell!=null && cell.SelfReferenceLayout!=null)
{
foreach (RadElement item in cell.SelfReferenceLayout.StackLayoutElement.Children)
{
if (!(item is GridTreeExpanderItem))
{
item.Visibility = ElementVisibility.Collapsed;
}
else
{
item.Visibility = ElementVisibility.Visible;
}
}
}
}
Use attached to reproduce. Workaround: DragDropService.AllowAutoScrollColumnsWhileDragging = false; DragDropService.AllowAutoScrollRowsWhileDragging = false;
Use attached to reproduce.
Workaround:
this.LoadFieldList(hiddenGrid.MasterTemplate);
this.FieldList.Add(new Telerik.Data.Expressions.ExpressionItem()
{ Name = "Test", Description = "Test", Syntax = "Test", Type = Telerik.Data.Expressions.ExpressionItemType.Field, Value = "Test" });
Please refer to the attached sample project. The ResizeColumnsProportionally.gif illustrates the correct behavior of columns resizing. However, if you make a certain column with fixed size, the columns resizing is not proportional any more. The ColumnsWidthNOTAdjustedProportionally.gif demonstrates better the wrong behavior. Workaround: handle the SizeChanged event and adjust the columns' width property programmatically in order to obtain the desired widths.
To reproduce:
Public Class RadForm1
Public RadGridView1 As RadGridView
Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles Me.Load
CreateGrid()
FormatGrid()
SetDataSource()
End Sub
Private Sub CreateGrid()
Try
RadGridView1 = New RadGridView
Me.Controls.Add(RadGridView1)
Catch ex As Exception
MessageBox.Show(Me, ex.Message)
End Try
End Sub
Private Sub FormatGrid()
Dim col As GridViewTextBoxColumn
With RadGridView1
col = New GridViewTextBoxColumn
With col
.FieldName = "FieldID"
'NOTE: Comment out NullValue = "" to prevent the unhandled exception
.NullValue = ""
End With
.Columns.Add(col)
End With
End Sub
Private Sub SetDataSource()
Dim table As DataTable = Nothing
Dim row As DataRow = Nothing
table = New DataTable("GridList")
table.Columns.Add("FieldID", GetType(System.Guid))
row = table.NewRow
row("FieldID") = Guid.Empty
table.Rows.Add(row)
RadGridView1.DataSource = table
End Sub
End Class
Workaround:
Comment this line
NullValue = ""
Use attached to reproduce. Workaround - Set the position at runtime. Me.radGridView1.MasterTemplate.AddNewRowPosition = Telerik.WinControls.UI.SystemRowPosition.Bottom
To reproduce: if you pin a calculator or a hyperlink column you will notice that the cells belonging to these columns remain white. However, the cells from other column types have a light blue/gray fill color for pinned state.
Workaround:
private void RadGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.Column.IsPinned)
{
e.CellElement.BackColor = Color.FromArgb(235, 244, 252);
}
else
{
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
}
}
To reproduce: please refer to the attached screenshot. Workaround: add the FilterDescriptor programmatically: https://docs.telerik.com/devtools/winforms/gridview/filtering/setting-filters-programmatically-(simple-descriptors)
Excel does not support dates prior to 1/1/1900, however, we could export such dates as simple strings: https://support.office.com/en-us/article/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
How to reproduce:
public partial class Form1 : RadForm
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetData();
this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
}
private object GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Bool", typeof(bool));
dt.Columns.Add("Date", typeof(DateTime));
DateTime date = new DateTime(1850, 1, 1);
for (int i = 0; i < 100; i++)
{
dt.Rows.Add(i, "Name " + i, i % 2 == 0, date.AddYears(i));
}
return dt;
}
FieldInfo fi;
private void radButton1_Click(object sender, EventArgs e)
{
//Old Export using the ExcelML format
this.fi = typeof(Telerik.WinControls.UI.Export.ExcelML.CellElement).GetField("_dataElement", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
ExportToExcelML exporter = new ExportToExcelML(this.radGridView1);
string fileName = @"..\..\data.xls";
exporter.RunExport(fileName);
//New export utilizing the SpreadProcessing libraries
GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1);
SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
spreadExporter.RunExport(@"..\..\data.xlsx", exportRenderer);
}
}
Workaround: handle the CellFormatting event
public partial class Form1 : RadForm
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetData();
this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
}
private object GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Bool", typeof(bool));
dt.Columns.Add("Date", typeof(DateTime));
DateTime date = new DateTime(1850, 1, 1);
for (int i = 0; i < 100; i++)
{
dt.Rows.Add(i, "Name " + i, i % 2 == 0, date.AddYears(i));
}
return dt;
}
FieldInfo fi;
private void radButton1_Click(object sender, EventArgs e)
{
//Old Export using the ExcelML format
this.fi = typeof(Telerik.WinControls.UI.Export.ExcelML.CellElement).GetField("_dataElement", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
ExportToExcelML exporter = new ExportToExcelML(this.radGridView1);
exporter.ExcelCellFormatting += Exporter_ExcelCellFormatting;
string fileName = @"..\..\data.xls";
exporter.RunExport(fileName);
//New export utilizing the SpreadProcessing libraries
GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1);
spreadExporter.CellFormatting += SpreadExporter_CellFormatting;
SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
spreadExporter.RunExport(@"..\..\data.xlsx", exportRenderer);
}
private void SpreadExporter_CellFormatting(object sender, Telerik.WinControls.Export.CellFormattingEventArgs e)
{
if (e.GridRowIndex >= 1 && e.GridCellInfo.ColumnInfo is GridViewDateTimeColumn && ((DateTime)e.GridCellInfo.Value).Year < 1900)
{
Telerik.Windows.Documents.Spreadsheet.Model.CellSelection cell = e.CellSelection as Telerik.Windows.Documents.Spreadsheet.Model.CellSelection;
cell.SetValue(e.GridCellInfo.Value.ToString());
}
}
private void Exporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
{
if (e.GridRowIndex > -1 && e.GridCellInfo.ColumnInfo is GridViewDateTimeColumn && ((DateTime)e.GridCellInfo.Value).Year < 1900)
{
DataElement data = new DataElement();
data.DataItem = e.GridCellInfo.Value.ToString();
this.fi.SetValue(e.ExcelCellElement, data);
}
}
}
Bind the grid to the following DataTable:
DataTable dt = new DataTable();
dt.Columns.Add("X.Y");
dt.Columns.Add("X");
dt.Rows.Add("Data X.Y", "Data X");
this.radGridView1.DataSource = dt;
You will notice that the second column "X" is missing.
Note: if you change the order of adding the columns, both columns will be added.
To reproduce: this.radGridView1.SummaryRowsBottom.Insert(0, summaryRowItem2); this.radGridView1.SummaryRowsBottom.Move(2, 0); Workaround: Remove all items and add them back with a spesific order.