ADD. RadGridView add functionality to support the NOT operator while filtering i.e Not Starts With, Not Equals etc
FIX. RadGridView ComboBoxColumn when in data bound mode with auto complete set to SuggestAppend wrong results might be obtained. How to reporduce: Use RadGridView with ComboBoxColumn and set AutoCompleteMode to SuggestAppend. Also set DropDownStyle to DropDown. When start typing if nonexisting item gets typed the column will append the closest available item to the cell.
To reproduce: - Create a GridViewMaskBoxColumn with standard mask type and mask set to "aaaaaaaaaa". - Bind the grid to the following DataTable: private static DataTable GridDataTable() { DataRow dr = default(DataRow); DataTable dt = new DataTable(); dt.Columns.Add("Description"); dr = dt.NewRow(); dr[0] = "1234567890"; dt.Rows.Add(dr); dr = dt.NewRow(); dr[0] = "abc"; dt.Rows.Add(dr); return dt; } - Click the first cell in order to enter in edit mode. - Click the second cell and you will notice that the text is wrong. Workaround: - change the value in the CellEditor intialized event handler: void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { if (e.ActiveEditor is RadMaskedEditBoxEditor) { RadMaskedEditBoxEditor editor = e.ActiveEditor as RadMaskedEditBoxEditor; editor.MaskTextBox.Value = "___________"; editor.MaskTextBox.Value = (string)radGridView1.CurrentCell.Value; } }
To reproduce: public Form1() { InitializeComponent(); for (int i = 0; i < 10; i++) { this.radGridView1.Columns.Add("Col"+i); } this.radGridView1.TableElement.RowDragHint = null; } Workaround: public Form1() { InitializeComponent(); for (int i = 0; i < 10; i++) { this.radGridView1.Columns.Add("Col"+i); } this.radGridView1.TableElement.RowDragHint = null; CustomRadGridViewDragDropService service = new CustomRadGridViewDragDropService(this.radGridView1.GridViewElement); this.radGridView1.GridViewElement.RegisterService(service); } public class CustomRadGridViewDragDropService : RadGridViewDragDropService { public CustomRadGridViewDragDropService(RadGridViewElement gridViewElement) : base(gridViewElement) { } public override string Name { get { return typeof(RadGridViewDragDropService).Name; } } protected override void PrepareDragHint(ISupportDrop dropTarget) { if (this.GridViewElement.TableElement.RowDragHint == null) { return; } base.PrepareDragHint(dropTarget); } protected override IGridDragDropBehavior GetDragDropBehavior() { IGridDragDropBehavior behavior = null; ISupportDrop dropTarget = this.DropTarget; if (dropTarget is GridHeaderCellElement) { behavior = new CustomGridColumnDragDropBehvavior(); return behavior; } return base.GetDragDropBehavior(); } } public class CustomGridColumnDragDropBehvavior : GridColumnDragDropBehvavior { public override Size GetDragHintSize(ISupportDrop dropTarget) { if (this.DragHint==null) { return new Size(0, 0); } return base.GetDragHintSize(dropTarget); } }
FIX. RadGridView - add property to GridSpinEditorElement which will prevent the value changing with mouse wheel
To reproduce: 1.Set the GridView template's ViewDefinition to ColumnGroups 2.Add a new column 3.Delete the column 4.Add another new column. The PropertyBuilder closes and it is not possible to open the Smart Tag of RadGridView anymore. Please refer to the attached gif file. Workaround: The issue is caused by a remaining reference to a deleted column. When using the RadGridView PropertyBuilder and a column is added to ColumnGroupsViewDefinition, once the column is deleted from RadGridView (via the Property Builder) the code for adding the column in the ColumnGroupsViewDefinition remains, and this causes further designer instability with the Property Builder. To handle this scenario there are two options: 1. When a column is deleted via Property Builder, and this column was part of ColumnGroupsViewDefinition, open the Designer.cs/vb file, locate the line that adds this column to a ColumnNames collection and delete it. It should be something like: gridViewColumnGroupRow3.ColumnNames.Add("column1"); - where "column1" is the name of the deleted column 2. Instead of using the Property Builder to build the ColumnGroupsViewDefinition, build it programmatically.
Excluding certain properties when layout is being saved
ADD. RadTimePicker localization provider
Workaround, use the Pasting event of RadGridView and perform the needed validation
If you dispose the grid or the form it is placed on the grid's DoubleClick, MouseDoubleClick, MouseDown, etc. events, an exception is thrown.
Steps to reproduce: 1. Add a RadGridView to a form. 2. Add a code that would load data in the RadGridView from an IDataReader: radGridView1.MasterTemplate.LoadFrom(iReader); 3. Set EnableAlternatingRowColor to true and set some AlternatingRowColor 4. Run the project and you will see that the alternating row color is not applied.
To reproduce: - Create a RadGridView with 3 columns. - Set ShowRowHeaderColumn to false. - Set GridViewAutoSizeColumnsMode to Fill. - Select a cell and hit the TAB key multiple times. Notice the entire grid shift left and right.
The following strings on the print settings dialog of RadGridView cannot be localized: "Page fit mode", "Print:", "Alternating row color", "Summary cells"
IIF function in Expression for calculated columns does not work.
The issue appears when the form with the control inherits from a base form with added controls in it. The base form is a RadForm.
To reproduce: Add a RadGridView wth a few columns ,add rows as a few rows should have increasingly long text. Right click on the header cell to show the context menu and click bestfit. You will notice that the size of the column is not correct Workaround: void grid_MouseMove(object sender, MouseEventArgs e) { this.mouseLocation = e.Location; } private Point mouseLocation; private GridViewColumn currentColumn; void grid_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { if (this.grid.CurrentRow is GridViewHierarchyRowInfo) { RadItem bestFitItem = e.ContextMenu.Items.FirstOrDefault(x => x.Text == "Best Fit"); if (bestFitItem != null) { e.ContextMenu.Items.Remove(bestFitItem); } RadMenuItem newBestFitItem = new RadMenuItem { Text = "Best Fit" }; this.currentColumn = (this.grid.ElementTree.GetElementAtPoint(this.mouseLocation) as GridCellElement).ColumnInfo; newBestFitItem.Click += newBestFitItem_Click; e.ContextMenu.Items.Add(newBestFitItem); } } void newBestFitItem_Click(object sender, EventArgs e) { int highestWidth = this.GetHeightestWidthFromColumn(this.currentColumn); this.currentColumn.Width = highestWidth; } private int GetHeightestWidthFromColumn(GridViewColumn gridViewColumn) { int max = int.MinValue; Font cellFont = this.grid.TableElement.VisualRows[0].VisualCells[0].Font; for (int i = 0; i < this.grid.Rows.Count; i++) { int textWidth = TextRenderer.MeasureText(this.grid.Rows[i].Cells[gridViewColumn.Index].Value + "", cellFont).Width; if (max < textWidth) { max = textWidth; } } return max; }
The check box should be placed in the header cell (if the users wants to). Additionally it should be able to control both one level and hierarchy Resolution: You need to set the EnableHeaderCheckBox property to true. Please refer in help article for more information: http://www.telerik.com/help/winforms/gridview-columns-gridviewcheckboxcolumn.html
How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); GridViewComboBoxColumn supplierColumn = new GridViewComboBoxColumn(); supplierColumn.Name = "SupplierColumn"; supplierColumn.HeaderText = "Supplier"; supplierColumn.DataSource = this.GetListItemData(); ; supplierColumn.ValueMember = "Id"; supplierColumn.DisplayMember = "Description"; supplierColumn.Width = 200; this.radGridView1.Columns.Add(supplierColumn); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.CellEditorInitialized += RadGridView1_CellEditorInitialized; } private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor; if (editor == null) { return; } RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement; element.ValueChanging -= Element_ValueChanging; element.ValueChanging += Element_ValueChanging; } private void Element_ValueChanging(object sender, ValueChangingEventArgs e) { Console.WriteLine("ValueChanging"); Console.WriteLine("Old " + e.OldValue); Console.WriteLine("New " + e.NewValue); } private object GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Date", typeof(DateTime)); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i)); } return dt; } public List<Item> GetListItemData() { List<Item> items = new List<Item>(); for (int i = 0; i < 10; i++) { items.Add(new Item(i, "Data" + i, DateTime.Now.AddDays(i).AddHours(i))); } return items; } } public class Item { public int Id { get; set; } public string Description { get; set; } public DateTime Date { get; set; } public Item(int id, string description, DateTime date) { this.Id = id; this.Description = description; this.Date = date; } } Workaround: handle the TextChanging event and store locally the old value private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor; if (editor == null) { return; } RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement; element.TextChanging-= Element_TextChanging; element.TextChanging += Element_TextChanging; element.ValueChanging -= Element_ValueChanging; element.ValueChanging += Element_ValueChanging; } object oldValue; private void Element_TextChanging(object sender, TextChangingEventArgs e) { oldValue = e.OldValue; } private void Element_ValueChanging(object sender, ValueChangingEventArgs e) { Console.WriteLine("ValueChanging"); Console.WriteLine("Old " + oldValue); Console.WriteLine("New " + e.NewValue); }
To reproduce: -add RadGridView and RadButton to the form; -apply Office2010Black to the grid; -use the following code: private DataTable dataTable; public Form1() { InitializeComponent(); radGridView1.AutoSizeRows = false; radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.RowFormatting += radGridView1_RowFormatting; radGridView1.ReadOnly = true; radGridView1.ShowRowHeaderColumn = false; radGridView1.VerticalScrollState = ScrollState.AlwaysShow; radGridView1.ThemeName = "Office2010Black"; dataTable = new DataTable(); dataTable.Columns.Add("number", typeof(int)); dataTable.Columns.Add("descriptions", typeof(string)); radGridView1.DataSource = dataTable; } void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e) { e.RowElement.RowInfo.Height = 120; } private void radButton1_Click(object sender, EventArgs e) { radGridView1.Enabled = false; Random rnd = new Random((int)DateTime.Now.Ticks); dataTable.Clear(); for (int i = 0; i < rnd.Next(1000); i++) { DataRow row = dataTable.NewRow(); row[0] = i + 1; row[1] = "description" + i.ToString(); dataTable.Rows.Add(row); } radGridView1.Enabled = true; } After clicking the button, notice that the vertical scroll bar is not painted correctly and it is resized when scrolling. Workaround: Update the button Click event as follows: private void radButton1_Click(object sender, EventArgs e) { radGridView1.VerticalScrollState = ScrollState.AlwaysHide; radGridView1.Enabled = false; radGridView1.BeginEdit(); Random rnd = new Random((int)DateTime.Now.Ticks); dataTable.Clear(); for (int i = 0; i < rnd.Next(1000); i++) { DataRow row = dataTable.NewRow(); row[0] = i + 1; row[1] = "description" + i.ToString(); dataTable.Rows.Add(row); } radGridView1.EndEdit(); radGridView1.Enabled = true; radGridView1.VerticalScrollState = ScrollState.AlwaysShow; radGridView1.TableElement.VScrollBar.ResetLayout(true); radGridView1.MasterTemplate.Refresh(); radGridView1.TableElement.ScrollToRow(radGridView1.CurrentRow); }
How to reproduce public partial class Form1 : RadForm { public Form1() { InitializeComponent(); GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn(); textBoxColumn.Name = "Column"; textBoxColumn.HeaderText = "Column"; this.radGridView1.MasterTemplate.Columns.Add(textBoxColumn); GridViewTextBoxColumn textBoxColumn2 = new GridViewTextBoxColumn(); textBoxColumn2.Name = "TextBoxColumn2"; textBoxColumn2.HeaderText = "ReadOnlyColumn"; this.radGridView1.MasterTemplate.Columns.Add(textBoxColumn2); for (int i = 0; i < 10; i++) { object v = i * 2; if (i % 3 == 0) { v = null; } this.radGridView1.Rows.Add(new object[] { i, v }); } this.radGridView1.MultiSelect = true; foreach (var row in this.radGridView1.Rows) { foreach (var cell in row.Cells) { GridViewCellInfo cellInfo = cell as GridViewCellInfo; if (cellInfo != null && cellInfo.RowInfo.Index % 3 == 0 && cellInfo.ColumnInfo.Index == 1) { cellInfo.ReadOnly = true; } } } } } Workaround: public class MyRadGridView : RadGridView { public override string ThemeClassName { get { return typeof(RadGridView).FullName; } } protected override RadGridViewElement CreateGridViewElement() { return new MyRadGridViewElement(); } } internal class MyRadGridViewElement : RadGridViewElement { protected override Type ThemeEffectiveType { get { return typeof(RadGridViewElement); } } protected override MasterGridViewTemplate CreateTemplate() { return new MyMasterGridViewTemplate(); } } internal class MyMasterGridViewTemplate : MasterGridViewTemplate { protected override void PasteDataToRow(List<string> rowData, GridViewRowInfo row) { { int colIndex = this.Owner.CurrentColumn.Index; int j = 0; while (j < rowData.Count && colIndex < this.CurrentView.ViewTemplate.ColumnCount) { GridViewColumn col = this.CurrentView.ViewTemplate.Columns[colIndex]; if (col.IsVisible && !col.ReadOnly && !row.Cells[colIndex].ReadOnly) { object value = rowData[j]; if (string.IsNullOrEmpty(rowData[j])) { value = null; } else if (this.CurrentView.ViewTemplate.Columns[colIndex].DataType == typeof(string)) { GridViewTextBoxColumn textColumn = col as GridViewTextBoxColumn; if (textColumn != null && textColumn.MaxLength > 0) { if (rowData[j].Length > textColumn.MaxLength) { value = rowData[j].Substring(0, textColumn.MaxLength); } } } else if (this.CurrentView.ViewTemplate.Columns[colIndex].DataType == typeof(DateTime)) { try { value = DateTime.Parse(rowData[j], this.CurrentView.ViewTemplate.Columns[colIndex].FormatInfo); } catch { } } else if (this.CurrentView.ViewTemplate.Columns[colIndex].DataType == typeof(Color)) { try { value = ColorTranslator.FromHtml(rowData[j]); } catch { } } if (this.ClipboardPasteMode == GridViewClipboardPasteMode.EnableWithNotifications) { CellValidatingEventArgs cellValidating = new CellValidatingEventArgs(row, col, value, row.Cells[colIndex].Value, null); this.EventDispatcher.RaiseEvent<CellValidatingEventArgs>(EventDispatcher.CellValidating, this, cellValidating); if (!cellValidating.Cancel) { row.Cells[colIndex].Value = value; CellValidatedEventArgs cellValidated = new CellValidatedEventArgs(row, col, value); this.EventDispatcher.RaiseEvent<CellValidatedEventArgs>(EventDispatcher.CellValidated, this, cellValidated); } } else { row.Cells[colIndex].Value = value; } j++; } colIndex++; } } } }