To reproduce:
public Form1()
{
InitializeComponent();
this.radGridView1.Columns.Add("Col1");
this.radGridView1.Rows.Add("word \u00AD word");
this.radGridView1.Rows.Add("word - word");
}
Workaround: replace "\u00AD" with "-"
private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
e.CellElement.Text = e.CellElement.Text.Replace("\u00AD", "-");
}
To reproduce: change the value for a GridCheckBoxCellElement. The editor is not active. However, if you click again over the current cell, the editor will be activated.
Workaround: use a custom row behavior to close the editor:
//register the custom row behavior
BaseGridBehavior gridBehavior = sourceRadGridView.GridBehavior as BaseGridBehavior;
gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior());
public class CustomGridDataRowBehavior : GridDataRowBehavior
{
public override bool OnMouseUp(MouseEventArgs e)
{
bool result = base.OnMouseUp(e);
if (this.MasterTemplate.CurrentColumn is GridViewCheckBoxColumn )
{
this.GridViewElement.EndEdit();
}
return result;
}
}
How to reproduce:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetData();
this.Load += Form1_Load;
}
private void Form1_Load(object sender, EventArgs e)
{
this.radGridView1.SynchronizeCurrentRowInSplitMode = true;
this.radGridView1.SplitMode = Telerik.WinControls.UI.RadGridViewSplitMode.Vertical;
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Age", typeof(int));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Bool", typeof(bool));
for (int i = 0; i < 100; i++)
{
dt.Rows.Add("Name " + i, i, DateTime.Now.AddMinutes(i), i % 2 == 0 ? true : false);
}
return dt;
}
}
Workaround:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetData();
this.radGridView1.ViewDefinition = new SplitViewDefintion();
this.Load += Form1_Load;
}
private void Form1_Load(object sender, EventArgs e)
{
this.radGridView1.SynchronizeCurrentRowInSplitMode = true;
this.radGridView1.SplitMode = Telerik.WinControls.UI.RadGridViewSplitMode.Vertical;
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Age", typeof(int));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Bool", typeof(bool));
for (int i = 0; i < 100; i++)
{
dt.Rows.Add("Name " + i, i, DateTime.Now.AddMinutes(i), i % 2 == 0 ? true : false);
}
return dt;
}
}
public class SplitViewDefintion : TableViewDefinition
{
public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
{
return new MyGridTableElement();
}
}
public class MyGridTableElement : GridTableElement
{
protected override RadScrollBarElement CreateScrollBarElement()
{
return new MyRadScrollbarElement();
}
}
public class MyRadScrollbarElement : RadScrollBarElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(RadScrollBarElement);
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (Cursor.Current == Cursors.SizeWE || Cursor.Current == Cursors.SizeNS)
{
return;
}
base.OnMouseDown(e);
}
}
Example : if we have 5 rows in the grid and if we copy 10 rows from excel and paste in first row, only first 5 records gets pasted and remaining 5 would be ignored.
To reproduce:
Sub New()
InitializeComponent()
Dim dt As New DataTable()
dt.Columns.Add("Name", GetType(String))
dt.Columns.Add("Price", GetType(Decimal))
dt.Columns.Add("Id", GetType(Integer))
dt.Columns.Add("ActivatedOn", GetType(DateTime))
For i As Integer = 0 To 4
dt.Rows.Add("Item" & i, i * 0.25, i, DateTime.Now.AddHours(i))
Next
Me.RadGridView1.DataSource = dt
Me.RadGridView1.Columns("Id").[ReadOnly] = True
Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
AddHandler Me.RadGridView1.DefaultValuesNeeded, AddressOf radGridView1_DefaultValuesNeeded
Me.RadGridView1.NewRowEnterKeyMode = RadGridViewNewRowEnterKeyMode.EnterMovesToLastAddedRow
End Sub
Private Sub radGridView1_DefaultValuesNeeded(sender As Object, e As GridViewRowEventArgs)
e.Row.Cells("Id").Value = Me.radGridView1.Rows.Count
e.Row.Cells("ActivatedOn").Value = DateTime.Now
End Sub
Select the read-only cell inside the new row and press Enter. You will notice that two duplicated rows are added.
Workaround: handle the RadGridView.PreviewKeyDown event and change the current column to one that is not read-only
AddHandler Me.RadGridView1.PreviewKeyDown, AddressOf GridPreviewKeyDown
Private Sub GridPreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs)
If e.KeyCode = Keys.Enter Then
Me.RadGridView1.CurrentColumn = Me.RadGridView1.Columns(0)
Me.RadGridView1.BeginEdit()
End If
End Sub
To reproduce:
1. Bind RadGridView to a collection of business objects where one of the properties is Nullable<DateTime>.
2. Leave one of the items with an empty date (null value).
3. Copy the entire row and try to paste in one of the grid rows. The FormatException is thrown.
Sub New()
InitializeComponent()
Dim items As New List(Of Item)
items.Add(New Item(1, DateTime.Now.AddDays(2), "Item1"))
items.Add(New Item(2, Nothing, "Item2"))
items.Add(New Item(3, DateTime.Now.AddDays(4), "Item3"))
items.Add(New Item(4, DateTime.Now.AddDays(5), "Item4"))
Me.RadGridView1.DataSource = items
Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
End Sub
Public Class Item
Private _id As Integer
Private _createdOn As Nullable(Of DateTime)
Private _title As String
Public Sub New(id As Integer, createdOn As Nullable(Of DateTime), title As String)
Me._id = id
Me._createdOn = createdOn
Me._title = title
End Sub
Public Property Id() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
Public Property CreatedOn() As Nullable(Of DateTime)
Get
Return _createdOn
End Get
Set(ByVal value As Nullable(Of DateTime))
_createdOn = value
End Set
End Property
Public Property Title() As String
Get
Return _title
End Get
Set(ByVal value As String)
_title = value
End Set
End Property
End Class
Workaround: use a TypeConverter
Sub New()
InitializeComponent()
Dim items As New List(Of Item)
items.Add(New Item(1, DateTime.Now.AddDays(2), "Item1"))
items.Add(New Item(2, Nothing, "Item2"))
items.Add(New Item(3, DateTime.Now.AddDays(4), "Item3"))
items.Add(New Item(4, DateTime.Now.AddDays(5), "Item4"))
Me.RadGridView1.DataSource = items
Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
DirectCast(Me.RadGridView1.Columns(1), GridViewDateTimeColumn).DataTypeConverter=New NullableDateTimeConverter()
End Sub
Public Class NullableDateTimeConverter
Inherits TypeConverter
Public Overrides Function CanConvertFrom(ByVal context As ITypeDescriptorContext, ByVal sourceType As Type) As Boolean
Return sourceType.Equals(GetType(String))
End Function
Public Overrides Function ConvertFrom(ByVal context As ITypeDescriptorContext, ByVal culture As CultureInfo, ByVal value As Object) As Object
Dim parsedDate As DateTime
If DateTime.TryParse(value.ToString(), parsedDate) Then
Return parsedDate
End If
Return Nothing
End Function
End Class
Public Class Item
Private _id As Integer
Private _createdOn As Nullable(Of DateTime)
Private _title As String
Public Sub New(id As Integer, createdOn As Nullable(Of DateTime), title As String)
Me._id = id
Me._createdOn = createdOn
Me._title = title
End Sub
Public Property Id() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
Public Property CreatedOn() As Nullable(Of DateTime)
Get
Return _createdOn
End Get
Set(ByVal value As Nullable(Of DateTime))
_createdOn = value
End Set
End Property
Public Property Title() As String
Get
Return _title
End Get
Set(ByVal value As String)
_title = value
End Set
End Property
End Class
"High Performance with RadGridView and Virtual Mode including Filtering, Sorting and Grouping" example is not working for RadGridView Q3 2015. When I click on the Column header for sorting ( same thing for grouping and filtering) and I m getting exception "Sorting operation is not supported in VirtualMode.". Same sample is working for Q3 2014. Following is the URL for the sample http://www.telerik.com/support/kb/winforms/gridview/details/high-performance-with-radgridview-and-virtual-mode-including-filtering-sorting-and-grouping
To reproduce: - Group the grid first. Make sure there are enough rows for two pages. - Set the AutoSizeRows property to true. Workaround: Set AutoSizeRows to false while printing.
For now you can manually add the columns to the ExcelFilteredColumns collection when the filters are added in code:
FilterDescriptor fd = new FilterDescriptor("Value", Telerik.WinControls.Data.FilterOperator.IsEqualTo, "B");
fd.IsFilterEditor = true;
radGridView1.FilterDescriptors.Add(fd);
this.radGridView1.MasterTemplate.ExcelFilteredColumns.Add( this.radGridView1.Columns[0] );
To reproduce - Add condition formatting object that changes the font. - Add cell style that changes the background only. Workaraound: Use the CellFormatting event instead of a style.
To reproduce:
GridViewHyperlinkColumn col = new GridViewHyperlinkColumn();
col.FieldName = "Name";
col.HyperlinkOpenAction = HyperlinkOpenAction.DoubleClick;
Workaround:
Use the CellDoubleClick event:
void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
{
if (e.Column is GridViewHyperlinkColumn)
{
string hyperlink = e.Value.ToString();
}
}
To reproduce:
1. Add a UserControl and drop a RadGridView in it.
2. Use the following code:
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
this.radGridView1.ViewDefinition = view;
view.ColumnGroups.Add(new GridViewColumnGroup("Group"));
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow() );
GridViewTextBoxColumn col = new GridViewTextBoxColumn("Col1");
this.radGridView1.Columns.Add(col);
view.ColumnGroups[0].Rows[0].ColumnNames.Add("Col1");
}
}
3. Drag the UserControl from the Toolbox to the form.
Workaround: set the ViewDefinition property after all columns are added.
To reproduce: - Add textbox and checkbox columns to a grid the checkbox column should not be visible without scrolling to the right. - Change the data source in the FilterChanged event. - Test this by moving the checkbox column in front of the text box column.
How to reproduce:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetData();
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
foreach (var col in this.radGridView1.Columns)
{
col.HeaderTextAlignment = ContentAlignment.MiddleLeft;
}
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Bool", typeof(bool));
dt.Columns.Add("Bool1", typeof(bool));
dt.Columns.Add("Bool2", typeof(bool));
for (int i = 0; i < 50; i++)
{
dt.Rows.Add("Name " + i, DateTime.Now.AddMinutes(i), i % 2 == 0 ? true : false, false, false);
}
return dt;
}
private void radButton1_Click(object sender, EventArgs e)
{
this.radGridView1.PrintPreview();
}
}
Workaround:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radGridView1.DataSource = this.GetData();
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.radGridView1.PrintCellFormatting += radGridView1_PrintCellFormatting;
foreach (var col in this.radGridView1.Columns)
{
col.HeaderTextAlignment = ContentAlignment.MiddleLeft;
}
}
private void radGridView1_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e)
{
if (e.Row is GridViewTableHeaderRowInfo && this.radGridView1.RightToLeft == System.Windows.Forms.RightToLeft.Yes)
{
e.PrintCell.TextAlignment = ContentAlignment.MiddleRight;
}
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Bool", typeof(bool));
dt.Columns.Add("Bool1", typeof(bool));
dt.Columns.Add("Bool2", typeof(bool));
for (int i = 0; i < 50; i++)
{
dt.Rows.Add("Name " + i, DateTime.Now.AddMinutes(i), i % 2 == 0 ? true : false, false, false);
}
return dt;
}
private void radButton1_Click(object sender, EventArgs e)
{
this.radGridView1.PrintPreview();
}
}
To reproduce: - Create a new Visual Studio project with a single form. - Add a RadGridView control to the form. - Add a child Template to the RadGridView. - In the properties of this child template, enable AutoExpand Groups. - Close the form editor and re-open.
Workaround: custom RadGridViewDragDropService and an override of the HandleMouseMove method, please check the attached project
To reproduce: use the following code snippet and follow the steps from the attached gif file.
public Form1()
{
InitializeComponent();
List<Item> items = new List<Item>();
for (int i = 1; i < 10; i++)
{
items.Add(new Item(i, 0, "Item" + i));
}
Random rand = new Random();
for (int i = 10; i < 50; i++)
{
items.Add(new Item(i, rand.Next(1, 10), "Item" + i));
}
this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "Id", "ParentId");
this.radGridView1.DataSource = items;
this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowHeaderCellButtons = true;
}
public class Item
{
public int Id { get; set; }
public int ParentId { get; set; }
public string Name { get; set; }
public Item(int id, int parentId, string name)
{
this.Id = id;
this.ParentId = parentId;
this.Name = name;
}
}
Workaround: use the basic filtering