The RadGridView is bound to DataView Workaround: add row using the DataTable API: private void radButton1_Click(object sender, EventArgs e) { DataRow row = m_dvMat.Table.NewRow(); row["Active"] = true; row["Category"] = form.m_sString; m_dvMat.Table.Rows.Add(row); }
To reproduce: Add a TabControl and two tabs. In the second tab add a RadGridView and in the Load event of the form set the SplitMode property of the grid. You will notice that it will not have effect until grouping or other similar action has been performed. Workaround: private void Form1_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("column1"); dt.Columns.Add("column2"); RadGridView1.DataSource = dt; this.RadGridView1.VisibleChanged += Visible_Changed; } private void Visible_Changed(object sender, EventArgs e) { if (this.RadGridView1.Visible & !this.RadGridView1.SplitMode.Equals(Telerik.WinControls.UI.RadGridViewSplitMode.Horizontal)) { RadGridView1.SplitMode = Telerik.WinControls.UI.RadGridViewSplitMode.Horizontal; } }
To reproduce: Add a RadGridView and use the following code to populate it: for (int i = 0; i < 15; i++) { this.grid.Columns.Add(string.Format("Column {0}", i)); } for (int i = 0; i < this.grid.Columns.Count * 15; i++) { this.grid.Rows.AddNew(); }t Set the theme to TelerikMetroTouch. Scroll somewhere below the middle leave the scrollbar and leave the grid with the mouse. You will notice that the value of the scrollbar will change. Workaround: Subscribe to the RadPropertyChanging event of the TableElement: RadGridView1.TableElement.RadPropertyChanging += Property_Changing; void TableElement_RadPropertyChanging(object sender, RadPropertyChangingEventArgs args) { args.Cancel = args.Property == GridTableElement.RowHeightProperty || args.Property == GridTableElement.TableHeaderHeightProperty || args.Property == GridTableElement.GroupHeaderHeightProperty || args.Property == GridTableElement.FilterRowHeightProperty; }
To reproduce - add Calculator column in the grid - set the EnterKeyMode to EnterMovesToNextRow - press enter when the cell is in edit mode. Workaround: -use custom GridDataRowBehavior like this: class MyNewEnterBehavior : GridDataRowBehavior { bool firstTime = true; protected override bool ProcessEnterKey(KeyEventArgs keys) { if (this.GridControl.IsInEditMode && this.GridControl.CurrentColumn is GridViewCalculatorColumn ) { if (firstTime) { firstTime = false; return false; } firstTime = true; return base.ProcessEnterKey(keys); } return base.ProcessEnterKey(keys); } }
In RadGridView with a TextBoxColumn. Set WrapText, Multiline and AcceptsReturn to true If adding a new line, the return gives another new line instead of staying within the cell. Workaround: Create a new behavior class: //VB Class MyNewRowBehavior Inherits GridNewRowBehavior Protected Overrides Function ProcessEnterKey(keys As KeyEventArgs) As Boolean If Me.GridControl.IsInEditMode AndAlso Me.GridControl.CurrentColumn.Name = "TextBoxColumn" Then Dim editor As RadTextBoxEditor = TryCast(Me.GridControl.ActiveEditor, RadTextBoxEditor) Dim element As RadTextBoxEditorElement = DirectCast(editor.EditorElement, RadTextBoxEditorElement) element.Text.Insert(element.Text.Length, Environment.NewLine) Return True Else Return MyBase.ProcessEnterKey(keys) End If End Function End Class //C# class MyNewRowBehavior : GridNewRowBehavior { protected override bool ProcessEnterKey(KeyEventArgs keys) { if (this.GridControl.IsInEditMode && this.GridControl.CurrentColumn.Name == "TextBoxColumn") { RadTextBoxEditor editor = this.GridControl.ActiveEditor as RadTextBoxEditor; RadTextBoxEditorElement element = (RadTextBoxEditorElement)editor.EditorElement; element.Text.Insert(element.Text.Length, Environment.NewLine); return true; } else { return base.ProcessEnterKey(keys); } } } then unregister the old behavior and register the new one: //VB DirectCast(radGridView1.GridBehavior, BaseGridBehavior).UnregisterBehavior(GetType(GridViewNewRowInfo)) DirectCast(radGridView1.GridBehavior, BaseGridBehavior).RegisterBehavior(GetType(GridViewNewRowInfo), New MyNewRowBehavior()) //C# ((BaseGridBehavior)radGridView1.GridBehavior).UnregisterBehavior(typeof(GridViewNewRowInfo)); ((BaseGridBehavior)radGridView1.GridBehavior).RegisterBehavior(typeof(GridViewNewRowInfo), new MyNewRowBehavior());
Steps to reproduce: 1) Add RadGridView control 2) Use GridViewDecimalColumn: DataTable customDataTable = new DataTable(); sampleDataTable.Columns.Add("Column name", typeof(double)); 3) Set the right-to-left property of the control to true: this.radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes; 4) Re-size the form manually until horizontal scroll-bar appears and you will notice that the left border is missing Expected result: the left border of the GridRowHeaderCellElement is visible Actual result: the left border of the GridRowHeaderCellElement is missing Workaround: this.radGridView1.ViewCellFormatting +=new CellFormattingEventHandler(radGridView1_ViewCellFormatting); void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { if (e.CellElement is GridRowHeaderCellElement) { e.CellElement.BorderLeftWidth = 3; } }
To reproduce: Add a RadGridView to a form, dont dock it. Use the following code to add the rows, columns and the definition: this.Grid.Columns.Add("Old"); this.Grid.Columns.Add("New"); Start the application and you will see that you cannot scroll to the end, horizontally. Workaround: Use the following code on a button click or execute it in a timer a few millisecond after the form has loaded in order to update the scrollbar's maximum value accordingly: int width = 0; foreach (var col in this.Grid.Columns) { width += col.Width; } this.Grid.TableElement.HScrollBar.Maximum = width - this.Grid.TableElement.HScrollBar.SmallChange - this.Grid.TableElement.RowHeaderColumnWidth;
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
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.
The display member for empty string value in GridViewComboBoxColumn is not displayed. The following code reproduces the issue: GridViewComboBoxColumn cboInsRslCd = new GridViewComboBoxColumn(); cboInsRslCd.DataType = typeof(string); List<ItemComboBox> liste = new List<ItemComboBox>(); liste.Add(new ItemComboBox("", "[None]")); liste.Add(new ItemComboBox("A", "A")); liste.Add(new ItemComboBox("B", "B")); liste.Add(new ItemComboBox("C", "C")); cboInsRslCd.DataSource = liste; cboInsRslCd.ValueMember = "CleItem"; cboInsRslCd.DisplayMember = "ValeurItem"; cboInsRslCd.NullValue = "[None]"; this.radGridView1.Columns.Add(cboInsRslCd); WORKAROUND: subscribe to the CellEndEdit event and change the stored value in the event handler: private void RadGridView1_CellEndEdit(object sender, GridViewCellEventArgs e) { if (e.Value == null) { e.Row.Cells[e.Column.Name].Value = ""; } } http://www.telerik.com/community/forums/radgridview-comboboxcolumn-displays-no-value-for-member-with-empty-string-value-is-selected
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: -add a RadGridView and use the following code: public Form1() { InitializeComponent(); GridViewComboBoxColumn comboColumn = new GridViewComboBoxColumn("ComboBox column"); comboColumn.DataSource = new List<string>() { "first", "second", "third" }; radGridView1.Columns.Add(comboColumn); radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized; } private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDropDownListEditor dropDownEditor = radGridView1.ActiveEditor as RadDropDownListEditor; RadDropDownListEditorElement dropDownEditorElement = dropDownEditor.EditorElement as RadDropDownListEditorElement; dropDownEditorElement.SelectedIndex = 0; } If you try to add a new row in the grid, the first item in the RadDropDownListEditor is selected. If you do not make any selection changes and press Enter key, the new row will not be added. Workaround: use the DefaultValuesNeeded event for initializing RadDropDownListEditorElement's selectin
To reproduce: - Add logo in the header and export the document. Workaround: void exporter_HeaderExported(object sender, ExportEventArgs e) { PdfEditor ed = e.Editor as PdfEditor; using (MemoryStream ms = new MemoryStream()) { System.Drawing.Image.FromFile(@"C:\img\delete.png").Save(ms, System.Drawing.Imaging.ImageFormat.Png); ed.TranslatePosition(e.Rectangle.Width - 30, e.Rectangle.Y); ed.DrawImage(ms, new System.Windows.Size(30,30)); } }
A child row does not appear in the view by using following code snippet: GridViewRowInfo^ pNewRow = pTemplate->Rows->AddNew(); pNewRow->Cells["ChildNameColumn"]->Value = this->ChildTextBox->Text; int count = radGridView1->ChildRows->Count; pNewRow->Cells["ChildAddressColumn"]->Value = count.ToString() Workaround: add new rows in the following manner: private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { // add child row GridViewTemplate^ pTemplate = radGridView1->MasterTemplate->Templates[0]; GridViewRowInfo^ pNewRow = pTemplate->Rows->NewRow(); pNewRow->Cells["ChildNameColumn"]->Value = this->ChildTextBox->Text; int count = radGridView1->ChildRows->Count; pNewRow->Cells["ChildAddressColumn"]->Value = count.ToString(); pTemplate->Rows->Add(pNewRow); }
To reproduce: Dim dockmem As New MemoryStream Dim gridmem As New MemoryStream Public Sub SetData() ' dgvSelectList.DataSource = Nothing Dim dt As DataTable dt = New DataTable dt.Columns.Add("VENDCODE") dt.Columns.Add("VENDNAME") dt.Rows.Add("AA2", "Arthur") dt.Rows.Add("AA2", "Arthur") dgvSelectList.DataSource = dt dgvSelectList.BestFitColumns() End Sub Private Sub frmSelectListNG2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load SetData() dgvSelectList.EnableFiltering = False 'Save Grid and Dock layout settings to mem stream and simulate my process SaveSettings() End Sub Public Sub btnGO_Click(sender As System.Object, e As System.EventArgs) Handles btnGO.Click LoadSettings() dgvSelectList.SplitMode = RadGridViewSplitMode.Horizontal SetData() LoadSettings() End Sub Private Sub LoadSettings() gridmem.Position = 0 dockmem.Position = 0 dgvSelectList.LoadLayout(gridmem) rdkSelect.LoadFromXml(dockmem) End Sub Private Sub SaveSettings() gridmem.Position = 0 dockmem.Position = 0 dgvSelectList.SaveLayout(gridmem) rdkSelect.SaveToXml(dockmem) End Sub Workaround - set the datasource to Nothing prior rebinding
Advanced Property Grid in Property Builder filter the data source list and not show 'Project Data Sources' for selection in the DataSource popup. There is a difference in the drop down Datasource selection between the : GridviewDataColumn Collection Editor and the... RadGridView Property Builder
To reproduce: 1.Add a GridViewCheckBoxColumn and populate the grid with data: radGridView1.DataSource = Enumerable.Range(1, 100).Select(i => new { Check = i % 2 == 0}); 2.Add a RadButton and on its Click event clear the filters: private void radButton1_Click(object sender, EventArgs e) { radGridView1.MasterTemplate.FilterDescriptors.Clear(); } 3.Run the application and change the filter to show only checked items. Then click the button. The check box in the filtering row for GridViewCheckBoxColumn was not updated properly. Workaround: this.radGridView1.BeginUpdate(); radGridView1.MasterTemplate.FilterDescriptors.Clear(); this.radGridView1.EndUpdate();
Workaround: public Form1() { InitializeComponent(); radGridView1.CreateCell += radGridView1_CreateCell; } private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) { if (e.CellType == typeof(GridDataCellElement)) { e.CellElement = new CustomDataCell(e.Column,e.Row); } } public class CustomDataCell : GridDataCellElement { public CustomDataCell(GridViewColumn column, GridRowElement row) : base(column, row) { } protected override Type ThemeEffectiveType { get { return typeof(GridDataCellElement); } } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left && this.AllowRowReorder && this.ViewTemplate.AllowRowReorder && Cursor.Current != Cursors.SizeNS) { base.OnMouseDown(e); } } }
The example found here http://www.telerik.com/support/kb/winforms/gridview/details/high-performance-with-radgridview-and-virtual-mode-including-filtering-sorting-and-grouping, currently does not work. There should be a way for the example virtual grid to go past the current limitation in sorting, filtering and grouping.
How to reproduce: just create a grid with a great number of rows e.g. 15000 and scroll down using the page down key Workaround: public partial class Form1 : Form { public Form1() { InitializeComponent(); BaseGridBehavior gridBehavior = radGridView1.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior()); DataTable dataTable = new DataTable(); dataTable.Columns.Add("Id", typeof(int)); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("IsValid", typeof(bool)); for (int i = 0; i < 14000; i++) { dataTable.Rows.Add(i, "Name " + i, i % 2 == 0 ? true : false); } this.radGridView1.DataSource = dataTable; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; } } public class CustomGridDataRowBehavior : GridDataRowBehavior { protected override bool ProcessPageUpKey(KeyEventArgs keys) { GridTableElement tableElement = (GridTableElement)this.GridViewElement.CurrentView; int index = this.GridViewElement.CurrentRow.Index - tableElement.RowsPerPage + 1; if (index < 0) { index = 0; } GridViewRowInfo firstScrollableRow = this.GridControl.Rows[index]; this.GridViewElement.CurrentRow = firstScrollableRow; return true; } protected override bool ProcessPageDownKey(KeyEventArgs keys) { GridTableElement tableElement = (GridTableElement)this.GridViewElement.CurrentView; int index = this.GridViewElement.CurrentRow.Index + tableElement.RowsPerPage - 1; if (index > this.GridControl.Rows.Count - 1) { index = this.GridControl.Rows.Count - 1; } GridViewRowInfo lastScrollableRow = this.GridControl.Rows[index]; this.GridViewElement.CurrentRow = lastScrollableRow; return true; } }