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.
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);
}
}
ComboBox column DataSource property is not visible in the Designer MS Property Builder when the previously selected node was RadGridView.
Steps to reproduce:
1.Run the attached sample project.
2.Group by the ProductID column
3.Select Page 4
4. Expand the top group row. You will notice that the grid jumps to a previous row.
Expected:
Actual:
Workaround:
public class CustomGrid : RadGridView
{
public override string ThemeClassName
{
get
{
return typeof(RadGridView).FullName;
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
GridExpanderItem expander = this.ElementTree.GetElementAtPoint(e.Location) as GridExpanderItem;
if (expander != null)
{
flag = true;
}
base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
flag = false;
}
bool flag = false;
protected override void OnPageChanging(object sender, PageChangingEventArgs e)
{
if (flag)
{
e.Cancel = true;
}
base.OnPageChanging(sender, e);
}
}
When the RadGridView AutoSize property is set to true and a row is expanded, an exception is thrown:
System.InvalidOperationException: 'MeasureOverride returned positive infinity: Telerik.WinControls.UI.GridDetailViewRowElement'
A possible workaround is to replace the GridDetailViewRowElement with your own class. Then overriding the MeasureOverride method we can pass valid size to the element.
private void RadGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e)
{
if (e.RowInfo is GridViewDetailsRowInfo)
{
e.RowElement = new MyGridDetailViewRowElement();
}
}
public class MyGridDetailViewRowElement : GridDetailViewRowElement
{
protected override SizeF MeasureOverride(SizeF availableSize)
{
var baseSize = base.MeasureOverride(availableSize);
if(baseSize.Width == float.PositiveInfinity)
{
baseSize.Width = 800;
}
return baseSize;
}
}
Please refer to the sample project and open the Home form. The attached gif file illustrates how to reproduce the error.
Workaround: define the grid relations via code.
Use this XML layout:
this.radGridView1.LoadLayout(@"..\..\..\Layout.xml");
<RadGridView Padding="0, 0, 0, 1" Cursor="Default" TabIndex="49">
<MasterTemplate EnableGrouping = "True" AllowEditRow="False" AllowDeleteRow="False" AllowAddNewRow="False" EnableFiltering="True" AutoExpandGroups="True">
<Columns>
<Telerik.WinControls.UI.GridViewTextBoxColumn Width="100" FieldName="JobID" Name="JobID" IsAutoGenerated="True" IsVisible="True" HeaderText="JobID" />
<Telerik.WinControls.UI.GridViewTextBoxColumn Width="100" FieldName="CustomerID" Name="CustomerID" IsAutoGenerated="True" IsVisible="True" HeaderText="CustomerID" />
<Telerik.WinControls.UI.GridViewTextBoxColumn Width="285" FieldName="StatusID" Name="StatusID" IsAutoGenerated="True" IsVisible="True" HeaderText="StatusID" />
<Telerik.WinControls.UI.GridViewTextBoxColumn Width="100" FieldName="UnitID" Name="UnitID" IsAutoGenerated="True" IsVisible="True" HeaderText="UnitID" />
<Telerik.WinControls.UI.GridViewTextBoxColumn Width="100" FieldName="OperatorID" Name="OperatorID" IsAutoGenerated="True" IsVisible="True" HeaderText="OperatorID" />
<Telerik.WinControls.UI.GridViewTextBoxColumn Width="100" FieldName="JobTypeID" Name="JobTypeID" IsAutoGenerated="True" IsVisible="True" HeaderText="JobTypeID" />
<Telerik.WinControls.UI.GridViewTextBoxColumn Width="100" FieldName="JobCatID" Name="JobCatID" IsAutoGenerated="True" IsVisible="True" HeaderText="JobCatID" />
<Telerik.WinControls.UI.GridViewDateTimeColumn Width="100" FieldName="StartTime" Name="StartTime" IsAutoGenerated="True" IsVisible="True" HeaderText="StartTime">
<FilterDescriptor xsi:type="Telerik.WinControls.Data.DateFilterDescriptor" Value="" IgnoreTimePart="False" PropertyName="StartTime" Operator="IsNotNull" IsFilterEditor="True" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</Telerik.WinControls.UI.GridViewDateTimeColumn>
<Telerik.WinControls.UI.GridViewDateTimeColumn Width="100" FieldName="FinishTime" Name="FinishTime" IsAutoGenerated="True" IsVisible="True" HeaderText="FinishTime" />
<Telerik.WinControls.UI.GridViewDateTimeColumn Width="100" FieldName="CreateDate" Name="CreateDate" SortOrder="Descending" IsAutoGenerated="True" IsVisible="True" HeaderText="CreateDate" />
<Telerik.WinControls.UI.GridViewDateTimeColumn Width="100" FieldName="StatusJobDate" Name="StatusJobDate" IsAutoGenerated="True" IsVisible="True" HeaderText="StatusJobDate" />
<Telerik.WinControls.UI.GridViewTextBoxColumn Width="100" FieldName="UserID" Name="UserID" IsAutoGenerated="True" IsVisible="True" HeaderText="UserID" />
<Telerik.WinControls.UI.GridViewTextBoxColumn DataType="System.Guid" Width="100" FieldName="TableKey" Name="TableKey" IsAutoGenerated="True" IsVisible="False" HeaderText="TableKey" />
</Columns>
<FilterDescriptors>
<Telerik.WinControls.Data.DateFilterDescriptor Value="" IgnoreTimePart="False" PropertyName="StartTime" Operator="IsNotNull" IsFilterEditor="True" />
</FilterDescriptors>
<SortDescriptors>
<Telerik.WinControls.Data.SortDescriptor PropertyName="CreateDate" Direction="Descending" />
</SortDescriptors>
<ViewDefinition xsi:type="Telerik.WinControls.UI.TableViewDefinition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</MasterTemplate>
</RadGridView>
Workaround:
public class CustomGridView : RadGridView
{
protected override GridViewLayoutSerializer CreateGridViewLayoutSerializer(Telerik.WinControls.XmlSerialization.ComponentXmlSerializationInfo info)
{
return new CustomGridViewLayoutSerializer(info);
}
public override string ThemeClassName
{
get
{
return typeof(RadGridView).FullName;
}
}
}
public class CustomGridViewLayoutSerializer : GridViewLayoutSerializer
{
public CustomGridViewLayoutSerializer(ComponentXmlSerializationInfo componentSerializationInfo) : base(componentSerializationInfo)
{
}
protected override bool ProcessReaderAttribute(System.Xml.XmlReader reader, object parentObject, object toRead, PropertyDescriptor property)
{
if (toRead is FilterDescriptor && reader.Value == string.Empty)
{
object val = reader.Value;
if (property.ComponentType == typeof(DateFilterDescriptor))
{
val = null;
}
this.SetPropertyValue(property, toRead, val);
return true;
}
return base.ProcessReaderAttribute(reader, parentObject, toRead, property);
}
}
When we have column groups with equal names, the Spread Export is not exporting the groups correctly. This will lead to incorrectly merged cells.
A possible workaround is to assure that all column groups have different strings for their Text property.
Please run the sample project and follow the steps:
1.Open the attached solution in Visual Studio - I am using VS 2022.To reproduce, rebind the grid to a data table on button click and show grid's search row.
public RadForm1()
{
InitializeComponent();
this.radGridView1.AllowSearchRow = true;
}
private void RadButton1_Click()
{
DataTable dt = this.GetData();
this.radGridView1.DataSource = dt;
}
private DataTable GetData()
{
DataTable data = new DataTable();
for (int i = 0; i < 5; i++)
{
data.Columns.Add("Column " + i, typeof(int));
data.Columns.Add("Column " + i + 1, typeof(string));
data.Columns.Add("Column " + i + 2, typeof(string));
}
for (int k = 0; k < 5000; k++)
{
object[] parameters = new object[15];
for (int i = 0; i < 15; i += 3)
{
parameters[i] = k;
parameters[i + 1] = "Text " + i;
parameters[i + 2] = "Text " + i + 1;
}
data.Rows.Add(parameters);
}
return data;
}
Please use the attached sample project.
Hi There,
This call is only a nice to have, it is not critical at all. It is just a slight annoyance when building the Grid's columns - especially when there are many columns to adjust. My workflow is usually as follow.
Add all the columns needed, then after that I will run through all the columns and want to set the widths. But my speed is broken because I can't tab between the 3 width properties: Width, Min Width, Max Width. I have to click to put focus the the next value.
If possible, please can you correct the tab indexes?
Thank you
Kind Regards
Ben
PS. You may close this ticket immediately - this is only a request.