To reproduce: run the attached sample project and you will notice that the top border is missing as it is illustrated in the screenshot. Workaround: set the RadGridView.AutoSizeRows property to false.
To reproduce: public RadForm1() { InitializeComponent(); radGridView1.DataSource = GetTable(); GridViewSummaryItem summaryItem = new GridViewSummaryItem(); summaryItem.Name = "Name"; summaryItem.Aggregate = GridAggregateFunction.Count; GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(); summaryRowItem.Add(summaryItem); this.radGridView1.SummaryRowsBottom.Add(summaryRowItem); radGridView1.ViewCellFormatting += RadGridView1_ViewCellFormatting; } private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { if (e.CellElement is GridSummaryCellElement) { e.CellElement.DrawFill = true; e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid; e.CellElement.BackColor = Color.Red; } else { e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local); } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); radGridView1.MasterView.SummaryRows[0].PinPosition = PinnedRowPosition.Bottom; } static DataTable GetTable() { DataTable table = new DataTable(); table.Columns.Add("Dosage", typeof(int)); table.Columns.Add("Drug", typeof(string)); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Date", typeof(DateTime)); for (int i = 0; i < 5; i++) { table.Rows.Add(25, "Indocin", "David", DateTime.Now); table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now); table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now); table.Rows.Add(21, "Combivent", "Janet", DateTime.Now); table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now); } return table; } private void radButton1_Click(object sender, EventArgs e) { radGridView1.SaveLayout("test.xml"); } private void radButton2_Click(object sender, EventArgs e) { radGridView1.SummaryRowsBottom.Clear(); radGridView1.SummaryRowsTop.Clear(); radGridView1.LoadLayout("test.xml"); }
To reproduce: this.radGridView1.MultiSelect = true; this.radGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect; radGridView1.ShowRowHeaderColumn = false; Then select the cells in the firs column by dragging the mouse. Workaround: // radGridView1.ShowRowHeaderColumn = false; radGridView1.TableElement.RowHeaderColumnWidth = 0;
Workaround: handle the GridViewPdfExport.CellFormatting event and apply the column`s format string Public Class Form1 Sub New() InitializeComponent() Me.RadGridView1.DataSource = Me.GetData() Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill Dim decimalColumn = DirectCast(Me.RadGridView1.Columns("Money"), GridViewDecimalColumn) decimalColumn.DecimalPlaces = 0 decimalColumn.FormatString = "{0:C0}" Dim dateTimeColumn = DirectCast(Me.RadGridView1.Columns("Date"), GridViewDateTimeColumn) dateTimeColumn.FormatString = "{0:D}" End Sub Private Function GetData() As Object Dim dataTable As New DataTable() dataTable.Columns.Add("Id", GetType(Integer)) dataTable.Columns.Add("Name", GetType(String)) dataTable.Columns.Add("Money", GetType(Decimal)) dataTable.Columns.Add("Date", GetType(DateTime)) For i As Integer = 0 To 999 dataTable.Rows.Add(i, "Name " & i, i * 10, DateTime.Now.AddDays(i)) Next Return dataTable End Function Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim pdfExporter = New GridViewPdfExport(Me.RadGridView1) AddHandler pdfExporter.CellFormatting, AddressOf pdfExporter_CellFormatting Dim renderer = New PdfExportRenderer() Dim fileName As String = "..\..\exported-grid.pdf" pdfExporter.RunExport(fileName, renderer) End Sub Private Sub pdfExporter_CellFormatting(sender As Object, e As PdfExportCellFormattingEventArgs) If e.RowIndex > -1 Then e.CellElement.Text = TryCast(RadDataConverter.Instance.Format(e.Row.Cells(e.ColumnIndex).Value, GetType(String), e.Column), String) End If End Sub End Class
How to reproduce: public partial class Form1 : Form { private RadGridView grid = new RadGridView(); public Form1() { InitializeComponent(); Controls.Add(grid); grid.Dock = DockStyle.Fill; grid.DataSource = this.GetData(); } private object GetData() { DataTable dataTable = new DataTable(); dataTable.Columns.Add("Id", typeof(int)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Checked", typeof(bool)); for (int i = 0; i < 200; i++) { dataTable.Rows.Add(i, "Name " + i, i % 2 == 0); } return dataTable; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewCheckBoxColumn checkBoxColumn = (GridViewCheckBoxColumn)grid.Columns["Checked"]; checkBoxColumn.EnableHeaderCheckBox = true; checkBoxColumn.SortOrder = RadSortOrder.Ascending; } } Workaround: public partial class Form1 : Form { private RadGridView grid = new RadGridView(); public Form1() { InitializeComponent(); Controls.Add(grid); grid.Dock = DockStyle.Fill; grid.DataSource = this.GetData(); grid.MouseDown += grid_MouseDown; grid.MouseUp += grid_MouseUp; } private object GetData() { DataTable dataTable = new DataTable(); dataTable.Columns.Add("Id", typeof(int)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Checked", typeof(bool)); for (int i = 0; i < 200; i++) { dataTable.Rows.Add(i, "Name " + i, i % 2 == 0); } return dataTable; } private void grid_MouseDown(object sender, MouseEventArgs e) { RadGridView grid = (RadGridView)sender; RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement; if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement) { sw = new Stopwatch(); sw.Start(); grid.BeginUpdate(); } } Stopwatch sw; private void grid_MouseUp(object sender, MouseEventArgs e) { RadGridView grid = (RadGridView)sender; RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement; if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement) { grid.EndUpdate(); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewCheckBoxColumn checkBoxColumn = (GridViewCheckBoxColumn)grid.Columns["Checked"]; checkBoxColumn.EnableHeaderCheckBox = true; checkBoxColumn.SortOrder = RadSortOrder.Ascending; } }
To reproduce: please refer to the attached sample project and follow the steps in the provided gif file: 1. Enter something in the search bar 2. Filter on some column, uncheck "All", then select a few items, then validate 3. Click on a random row on the grid 4. Filter on the same column as in 2., check "All", then uncheck a few items, then validate Workaround: private void radGridView1_FilterChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e) { this.radGridView1.MasterTemplate.Refresh(); }
To reproduce - Start the attached project press "Add in code" then "Save" - The row is still not added to the underlying data table. Workaround: TryCast(Me.radGridView1.Rows.Last().DataBoundItem, IEditableObject).EndEdit()
Please refer to the attached sample project and gif file illustrating the behavior. ColumnGroupsViewDefinition view = this.radGridView1.ViewDefinition as ColumnGroupsViewDefinition; foreach (GridViewColumnGroup group in view.ColumnGroups) { group.ShowHeader = false; } Workaround: use the ViewCellFormatting and enable the back color for the header cells that are over the hidden group headers public RadForm1() { InitializeComponent(); ColumnGroupsViewDefinition view = this.radGridView1.ViewDefinition as ColumnGroupsViewDefinition ; foreach (GridViewColumnGroup group in view.ColumnGroups) { group.ShowHeader = false; } } private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { if (e.Row is GridViewTableHeaderRowInfo && !(e.CellElement is GridColumnGroupCellElement)) { e.CellElement.DrawFill = true; e.CellElement.BackColor = Color.FromArgb(234, 242, 252); e.CellElement.GradientStyle = GradientStyles.Solid; } else { e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local); } }
How to reproduce: public partial class Form1 : Form { public class Data { public bool Checked { get; set; } public string Text { get; set; } } private readonly RadGridView _grid; private readonly List<Data> _dataList = new List<Data> { new Data {Text = "abc"}, new Data {Text = "def"}, new Data {Text = "ghi"}, new Data {Text = "jkl"}, new Data {Text = "mno"}, new Data {Text = "pqr"}, new Data {Text = "stu"}, new Data {Text = "vwx"}, new Data {Text = "yz0"} }; public Form1() { InitializeComponent(); _grid = new RadGridView { Dock = DockStyle.Fill, AllowSearchRow = true }; Controls.Add(_grid); _grid.DataSource = _dataList; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); _grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; ((GridViewCheckBoxColumn)_grid.Columns["Checked"]).EnableHeaderCheckBox = true; _grid.Columns["Checked"].SortOrder = RadSortOrder.Ascending; ((GridViewCheckBoxColumn)_grid.Columns["Checked"]).Checked = ToggleState.On; _grid.MasterView.TableSearchRow.Search("abc"); } } Workaround: clear the search text protected override void OnLoad(EventArgs e) { base.OnLoad(e); _grid.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; ((GridViewCheckBoxColumn)_grid.Columns["Checked"]).EnableHeaderCheckBox = true; _grid.Columns["Checked"].SortOrder = RadSortOrder.Ascending; ((GridViewCheckBoxColumn)_grid.Columns["Checked"]).Checked = ToggleState.On; _grid.MasterView.TableSearchRow.Search("abc"); this._grid.MouseDown += _grid_MouseDown; } private void _grid_MouseDown(object sender, MouseEventArgs e) { RadGridView grid = (RadGridView)sender; RadCheckBoxElement cell = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckBoxElement; if (cell != null && cell.Parent is GridCheckBoxHeaderCellElement && grid.SortDescriptors.Count > 0)) { grid.MasterView.TableSearchRow.Search(""); } }
To reproduce: please refer to the attached gif file and sample project. Workaround: when you set the DrawFill property to true, specify the BackColor to the desired one and reset for the rest of the cells. private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) { if (e.Column.Name == "ProductName" && e.Row is GridViewDataRowInfo) { if (e.CellElement.Value.ToString().Contains("C")) { e.CellElement.DrawFill = true; e.CellElement.BackColor = Color.Yellow; e.CellElement.GradientStyle = GradientStyles.Solid; e.CellElement.ForeColor = Color.OliveDrab; } else { e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local); } } else { e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local); e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local); } }
To reproduce: protected override void OnLoad(EventArgs e) { base.OnLoad(e); DataTable dt = NewDt(); this.radGridView1.DataSource = dt; var c = this.radGridView1.Columns["Calculted"] as GridViewDecimalColumn; c.EnableExpressionEditor = true; c.Expression = "Column2 / SUM(Column2) * 10"; c.DecimalPlaces = 2; c.FormatString = "{0:N2}"; this.radGridView1.GroupDescriptors.Add("GroupByColumn", ListSortDirection.Ascending); } private DataTable NewDt() { var dt = new DataTable(); dt.Columns.Add("ItemColumn"); dt.Columns.Add("GroupByColumn"); dt.Columns.Add("Column2", typeof(decimal)); dt.Columns.Add("Calculted", typeof(decimal)); for (int i = 1; i <= 20; i++) { string gr = string.Empty; if (i % 3 == 0) gr = "gr3"; else if (i % 2 == 0) gr = "gr2"; else if (i % 5 == 0) gr = "gr5"; else gr = "item" + i.ToString(); dt.Rows.Add("id #" + i.ToString(), gr, i, 0); } return dt; } Workaround: public class CustomExpressionContext : Telerik.Data.Expressions.ExpressionContext { RadGridView radGridView; public CustomExpressionContext(RadGridView grid) { this.radGridView = grid; } public decimal MySum(string columnName) { decimal sum = 0; foreach (var item in radGridView.Rows) { sum += (decimal)item.Cells[columnName].Value; } return sum; } } Telerik.Data.Expressions.ExpressionContext.Context = new CustomExpressionContext(this.radGridView1);
To reproduce: please refer to the attached sample project and gif file illustrating the behavior. Add cell value in the new row and press teh down arrow. Workaround: this.radGridView1.MasterTemplate.SelectLastAddedRow = false; This problem is applicable for OpenEdge as well: http://knowledgebase.progress.com/articles/Article/Telerik-RadGridView-highlights-unnecessary-columns-and-rows-in-batch-mode
To reproduce: please refer to the attached sample project and gif file illustrating the behavior. Workaround: in order to cancel adding of the new row, you can call the MasterView.TableAddNewRow.CancelAddNewRow method: private void radGridView1_UserAddingRow(object sender, Telerik.WinControls.UI.GridViewRowCancelEventArgs e) { e.Cancel = true; this.radGridView1.MasterView.TableAddNewRow.CancelAddNewRow(); int index = this.radGridView1.Rows.Count; this.radGridView1.Rows.Add(index, "Row" + index); }
To reproduce: private void MasterTemplate_ViewChanged(object sender, DataViewChangedEventArgs args) { if (args.Action == ViewChangedAction.ExpandedChanged) { } } Workaround: - Use the GroupExpanded event.
To reproduce: - Add default values for all cells in the grid. - Try to add the new row without changing any value. Workaround: private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { var editor = radGridView1.ActiveEditor as BaseInputEditor; var field = editor.GetType().GetField("originalValue", BindingFlags.NonPublic | BindingFlags.Instance); field.SetValue(editor, "asd"); }
To reproduce: - Add DateTime columns to the grid and set the MaskType of the editor to FreeFormDateTime. - Go to the new row enter a valid date and press Tab. Workaround: class Myditor : RadDateTimeEditor { public override bool IsModified { get { return true; } } }
Please refer to the attached sample project and gif file illustrating the problem. Workaround: Sub New() InitializeComponent() AddHandler Me.RadGridView1.CreateCell, AddressOf RadGridView_CreateCell End Sub Public Class CustomGridFilterCellElement Inherits GridFilterCellElement Protected Overrides ReadOnly Property ThemeEffectiveType() As Type Get Return GetType(GridFilterCellElement) End Get End Property Public Sub New(column As GridViewDataColumn, row As GridRowElement) MyBase.New(column, row) End Sub Protected Overrides Function ApplyFormatString(value As Object) As String Return CDate(value).ToString("dd.MM.yyyy") End Function End Class
To reproduce: this.Controls.Add(this.radGridView1); this.radScheduler1.Dock = DockStyle.Fill; List<GridRec> records = new List<GridRec>(); GridRec rec = new GridRec(); rec.Column1 = "1"; rec.Column2 = "2"; rec.Column3 = "3"; rec.Column4 = "4"; rec.Column5 = "5"; rec.Column6 = "6"; rec.Column7 = "7"; rec.Column8 = "8"; rec.Column9 = "9"; for (int i = 0; i < 20; ++i) { records.Add(rec.Clone()); } radGridView1.DataSource = records; this.radGridView1.MultiSelect = true; this.radGridView1.SelectionMode = GridViewSelectionMode.CellSelect; this.radGridView1.Dock = DockStyle.Fill; public class GridRec { public GridRec Clone() { return this.MemberwiseClone() as GridRec; } public string Column1 { get; set; } public string Column2 { get; set; } public string Column3 { get; set; } public string Column4 { get; set; } public string Column5 { get; set; } public string Column6 { get; set; } public string Column7 { get; set; } public string Column8 { get; set; } public string Column9 { get; set; } } If you run the application, it starts with the upper-left most cell selected. Now, while holding down the Shift key, left-click on the cell in the 5th column of the 5th row (cell 5:5). Note all 25 cells are selected as expected. Now, while still holding Shift, left-click again on cell 5:5 and note the selection is cleared. Now, while still holding Shift, click on cell 4:4 (4th column, 4th row). Note how the selected range is now cells 1:1 through 4:4. And while still holding Shift, if you click on 4:4 yet again, the selection is cleared. Workaround: private void radGridView1_SelectionChanging(object sender, Telerik.WinControls.UI.GridViewSelectionCancelEventArgs e) { if (e.ColumnStartIndex == e.ColumnEndIndex && Control.ModifierKeys == Keys.Shift) { e.Cancel = true; } }
Use the attached project to reproduce. Workaround: Set the MaxWidth/MinWidth of the column manually.