Workaround: before printing set the AutoSizeRows = false, then you can set it again to true
private void radButton1_Click(object sender, EventArgs e)
{
if (!this.radGridView1.Columns["ImageColumn"].IsVisible)
{
int height = this.radGridView1.TableElement.ViewTemplate.Rows[0].Height;
this.radGridView1.AutoSizeRows = false;
this.radGridView1.TableElement.RowHeight = height;
}
this.radGridView1.PrintPreview();
this.radGridView1.AutoSizeRows = true;
}
To reproduce:
- Add ColumnGroupsViewDefinition and subscribe to ColumnWidthChanged event.
- Start the application and resize a column.
Workaround:
public class MyColumnGroupRowLayout : ColumnGroupRowLayout
{
public MyColumnGroupRowLayout(ColumnGroupsViewDefinition view) : base(view)
{
}
public override void ResizeColumn(int delta)
{
base.ResizeColumn(delta);
//This method will be called when a column is resized
}
}
class MyColumnGroupsViewDefinition : ColumnGroupsViewDefinition
{
public override IGridRowLayout CreateRowLayout()
{
return new MyColumnGroupRowLayout(this);
}
}
To reproduce:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)
Me.RadGridView1.DataSource = Me.CustomersBindingSource
Dim view As New ColumnGroupsViewDefinition()
view.ColumnGroups.Add(New GridViewColumnGroup("Customer Contact"))
view.ColumnGroups.Add(New GridViewColumnGroup("Details"))
view.ColumnGroups(1).Groups.Add(New GridViewColumnGroup("Address"))
view.ColumnGroups(1).Groups.Add(New GridViewColumnGroup("Contact"))
view.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow())
view.ColumnGroups(0).Rows(0).Columns.Add(Me.RadGridView1.Columns("CompanyName"))
view.ColumnGroups(0).Rows(0).Columns.Add(Me.RadGridView1.Columns("ContactName"))
view.ColumnGroups(0).Rows(0).Columns.Add(Me.RadGridView1.Columns("ContactTitle"))
view.ColumnGroups(1).Groups(0).Rows.Add(New GridViewColumnGroupRow())
view.ColumnGroups(1).Groups(0).Rows(0).Columns.Add(Me.RadGridView1.Columns("Address"))
view.ColumnGroups(1).Groups(0).Rows(0).Columns.Add(Me.RadGridView1.Columns("City"))
view.ColumnGroups(1).Groups(0).Rows(0).Columns.Add(Me.RadGridView1.Columns("Country"))
view.ColumnGroups(1).Groups(1).Rows.Add(New GridViewColumnGroupRow())
view.ColumnGroups(1).Groups(1).Rows(0).Columns.Add(Me.RadGridView1.Columns("Phone"))
view.ColumnGroups(1).Groups(1).Rows(0).Columns.Add(Me.RadGridView1.Columns("Fax"))
RadGridView1.ViewDefinition = view
RadGridView1.BestFitColumns(BestFitColumnMode.AllCells)
End Sub
Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
Dim spreadExporter As New GridViewSpreadExport(RadGridView1)
Dim fileName As String = "..\..\exported.xlsx"
Dim exportRenderer As New SpreadExportRenderer()
spreadExporter.SheetName = "Sheet1"
spreadExporter.ExportVisualSettings = True
spreadExporter.SummariesExportOption = SummariesOption.ExportOnlyTop
spreadExporter.SheetMaxRows = ExcelMaxRows._1048576
spreadExporter.HiddenColumnOption = HiddenOption.DoNotExport
spreadExporter.HiddenRowOption = HiddenOption.DoNotExport
spreadExporter.FileExportMode = FileExportMode.CreateOrOverrideFile
spreadExporter.RunExport(fileName, exportRenderer)
Process.Start(fileName)
End Sub
Workaround: by using the SpreadExportRenderer.WorkbookCreated event you can remove the header cells and add new ones in order to display the same header layout as in the grid:
http://www.telerik.com/help/winforms/gridview-exporting-data-spread-export.html
http://www.telerik.com/help/winforms/spreadprocessing-working-with-cells-insert-remove-cells.html
http://www.telerik.com/blogs/getting-started-with-radspreadprocessing-volume-1
To reproduce:
- Bind the grid to a DataView. The grid must have combo box column.
- Change the filter of the DataView like this:
Private Sub MasterTemplate_FilterExpressionChanged(sender As Object, e As FilterExpressionChangedEventArgs) Handles RadGridView.FilterExpressionChanged
_companies.RowFilter = e.FilterExpression
End Sub
- Set a filter to the combo box column and then set reset by selecting no filter in the drop down.
Workaround:
Public Class MyGridFilterComboBoxCellElement
Inherits GridFilterComboBoxCellElement
Public Sub New(ByVal col As GridViewDataColumn, ByVal row As GridRowElement)
MyBase.New(col, row)
End Sub
Protected Overrides Sub SetContentCore(ByVal value As Object)
If Me.ComboBoxColumnInfo IsNot Nothing Then
MyBase.SetContentCore(value)
End If
End Sub
End Class
Private Sub radGridView1_CreateCell(ByVal sender As Object, ByVal e As GridViewCreateCellEventArgs)
If e.CellType Is GetType(GridFilterComboBoxCellElement) Then
e.CellType = GetType(MyGridFilterComboBoxCellElement)
End If
End Sub
To reproduce:
1. Perform searching in the grid.
2. Sort by a random column.
3. Navigating with next/previous buttons do not navigate the results in the displayed order. Please refer to the attached gif file.
Workaround: clear the cache of the search row after sorting is changed:
private void radGridView1_SortChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{
string searchCriteria = this.radGridView1.MasterView.TableSearchRow.SearchCriteria;
FieldInfo fi = typeof(GridViewSearchRowInfo).GetField("cache",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
Hashtable cache = fi.GetValue(this.radGridView1.MasterView.TableSearchRow) as Hashtable;
cache.Clear();
this.radGridView1.MasterView.TableSearchRow.Search(searchCriteria);
}
To reproduce:
private void RadForm1_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("col1", typeof(bool));
dt.Columns.Add("col2", typeof(bool));
dt.Rows.Add(0, 1);
dt.Rows.Add(0, 1);
dt.Rows.Add(0, 1);
RadGridView1.DataSource = dt;
((Telerik.WinControls.UI.GridViewCheckBoxColumn)RadGridView1.Columns(0)).EnableHeaderCheckBox = true;
((Telerik.WinControls.UI.GridViewCheckBoxColumn)RadGridView1.Columns(1)).EnableHeaderCheckBox = true;
RadGridView1.HeaderCellToggleStateChanged += radGridView1_HeaderCellToggleStateChanged;
}
- Start the application and click in the second row in the first column.
Workaraound:
public class MyGridCheckBoxHeaderCellElement : GridCheckBoxHeaderCellElement
{
public MyGridCheckBoxHeaderCellElement(GridViewDataColumn col, GridRowElement row)
: base(col, row)
{ }
protected override void SetCheckBoxState(ToggleState state)
{
if (this.ColumnInfo.Name != this.GridViewElement.CurrentCell.ColumnInfo.Name)
{
return;
}
base.SetCheckBoxState(state);
}
}
To reproduce: - Remove the new row from the grid. - Start the application and delete all rows. - When the last row is deleted the SelectionChanged does not fire. Workaround: - Use the UserDeletedRow event instead.
To reproduce:
private void Form1_Load(object sender, EventArgs e)
{
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
this.radGridView1.DataSource = this.productsBindingSource;
GridViewSummaryItem summaryItem = new GridViewSummaryItem();
summaryItem.Name = "UnitPrice";
summaryItem.Aggregate = GridAggregateFunction.Count;
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
summaryRowItem.Add(summaryItem);
this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
GroupDescriptor descriptor1 = new GroupDescriptor();
descriptor1.GroupNames.Add("CategoryID", ListSortDirection.Ascending);
this.radGridView1.GroupDescriptors.Add(descriptor1);
GroupDescriptor descriptor11 = new GroupDescriptor();
descriptor11.GroupNames.Add("SupplierID", ListSortDirection.Ascending);
this.radGridView1.GroupDescriptors.Add(descriptor11);
GroupDescriptor descriptor2 = new GroupDescriptor();
descriptor2.GroupNames.Add("QuantityPerUnit", ListSortDirection.Ascending);
descriptor2.GroupNames.Add("UnitsInStock", ListSortDirection.Ascending);
this.radGridView1.GroupDescriptors.Add(descriptor2);
GroupDescriptor descriptor3 = new GroupDescriptor();
descriptor3.GroupNames.Add("UnitsOnOrder", ListSortDirection.Ascending);
descriptor3.GroupNames.Add("ReorderLevel", ListSortDirection.Descending);
this.radGridView1.GroupDescriptors.Add(descriptor3);
GroupDescriptor descriptor4 = new GroupDescriptor();
descriptor4.GroupNames.Add("Discontinued", ListSortDirection.Ascending);
this.radGridView1.GroupDescriptors.Add(descriptor4);
}
private void radButton1_Click(object sender, EventArgs e)
{
GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1);
SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
string filePath = @"..\..\exported" + DateTime.Now.ToShortTimeString().Replace(":", "_") + ".xlsx";
spreadExporter.ExportGroupedColumns = true;
spreadExporter.ExportChildRowsGrouped = true;
spreadExporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
spreadExporter.ExportVisualSettings = true;
spreadExporter.SummariesExportOption = Telerik.WinControls.UI.Export.SummariesOption.ExportAll;
spreadExporter.RunExport(filePath, exportRenderer);
Process.Start(filePath);
}
Workaround: set the ExportChildRowsGrouped property to false.
To reproduce: 1. Perform searching in the grid. 2. Group by a random column. 3. Navigating with next/previous buttons do not navigate the results in the displayed order. Workaround: set the EnablePaging property to false.
To reproduce:
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Rows.Add(1, new string('G', 32001));
this.radGridView1.DataSource = dt;
this.radGridView1.PrintPreview();
Workaround: this.radGridView1.PrintCellFormatting+=radGridView1_PrintCellFormatting;
private void radGridView1_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e)
{
e.PrintCell.Text = e.PrintCell.Text.Substring(0,Math.Min(e.PrintCell.Text.Length, 32000));
}
Currently, in order to display the "Deleter Row" context menu item, you should set both properties, AllowEditRow and AllowDeleteRow, to true. However, if you use the Delete key, it will remove the row if only the AllowDeleteRow property is set to true.
To reproduce: use DataAccess to connect to Northwind.Customer table:
public Form1()
{
InitializeComponent();
EntitiesModel1 context = new EntitiesModel1();
var query = (from c in context.Customers where c.CustomerID.Contains("f") select c).ToList();
this.radGridView1.DataSource = query;
SortDescriptor descriptor = new SortDescriptor();
descriptor.PropertyName = "CustomerID";
descriptor.Direction = ListSortDirection.Ascending;
this.radGridView1.MasterTemplate.SortDescriptors.Add(descriptor);
this.radGridView1.CurrentRow = this.radGridView1.Rows.Last();
}
Run the project and press the Delete key several times.
Workaround: use BindingSource as RadGridView.DataSource:
BindingSource bs = new BindingSource();
bs.DataSource = query;
this.radGridView1.DataSource = bs;
To reproduce: 1. Drag a grid from the Toolbox and drop it onto the form 2. Open the designer 3. Set the RadGridView.AutoGenerateHierarchy property to true. 4. Open the smart tag and set the DataSource property. As a result the grid templates and relations will be created. 5. Try to open the Property Builder. It opens successfully. 6. Close the Property Builder and add a new templated from the smart tag. 7. If you try to open the Property Builder again you will obtain the error. Please refer o the attached gif file illustrating the behavior. Workaround: set the AutoGenerateHierarchy to false in order to open the Property Builder.
To reproduce:
1. Add a RadGridView and a RadButton.
2. Use the following code snippet:
Public Class Form1
Private myList As New List(Of MyObject)
Sub New()
InitializeComponent()
PopulateGrid(300)
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
PopulateGrid(100)
End Sub
Private Sub PopulateGrid(count As Integer)
myList.Clear()
Me.RadGridView1.DataSource = Nothing
For index = 1 To count
myList.Add(New MyObject(index, "Item" & index))
Next
Me.RadGridView1.DataSource = myList
End Sub
Public Class MyObject
Public Sub New(ByVal myInt As Integer, ByVal myString As String)
_myInt = myInt
_myString = myString
End Sub
Private _myInt As Integer
Public Property MyInt() As Integer
Get
Return _myInt
End Get
Set(ByVal value As Integer)
_myInt = value
End Set
End Property
Private _myString As String
Public Property MyString() As String
Get
Return _myString
End Get
Set(ByVal value As String)
_myString = value
End Set
End Property
End Class
End Class
3. Select the last item
4. Click the button
Workaround: use BindingList instead of List
To reproduce:
- Set the first column header text to "+R/S";
- Export the grid with spread export.
Workaround:
class MySpreadExportRenderer : SpreadExportRenderer
{
public override void SetCellSelectionValue(string text)
{
if (text == "+R/S")
{
var cellSelection = typeof(SpreadExportRenderer).GetField("cellSelection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this) as CellSelection;
CellRange range = cellSelection.CellRanges.ElementAtOrDefault(0);
CellValueFormat cvf = new CellValueFormat("@");
var worksheet = typeof(SpreadExportRenderer).GetField("worksheet", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this) as Worksheet;
worksheet.Cells[range.FromIndex.RowIndex, range.FromIndex.ColumnIndex].SetFormat(cvf);
}
base.SetCellSelectionValue(text);
}
}
1 .Add RadgridView to Form 2. Set "AllowSearchRow" property to True 3. Add a row and place the word "Gießen" (name of a city) in a column 4. When the program is running type "Giessen" in the AutoSearch Row. After the "n" an ArgumentException is thrown.
How to reproduce:
Public Class Form1
Sub New()
InitializeComponent()
Dim col As New GridViewTextBoxColumn("Column1")
Me.RadGridView1.Columns.Add(col)
End Sub
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Dim sw As New Stopwatch
sw.Start()
Me.RadGridView1.Rows.Clear()
Me.RadGridView1.BeginUpdate()
Dim RowInfo
For ii = 1 To 100000
RowInfo = Me.RadGridView1.Rows.AddNew
RowInfo.Cells("Column1").Value = ii
Next
Me.RadGridView1.EndUpdate()
sw.Stop()
Console.WriteLine("Elapsed: " & sw.Elapsed.TotalSeconds)
End Sub
End Class
Workaround: add data to a collection and use bound mode
Introduce a property to change symbol used to separate summaryItems in SummaryRowGroupHeaders.
Workaround: check the attached project