To reproduce: public class Item { public int Id { get; set; } public string Name { get; set; } public DateTime Date { get; set; } public Item(int id, string name, DateTime date) { this.Id = id; this.Name = name; this.Date = date; } } public Form1() { InitializeComponent(); List<Item> items = new List<Item>(); for (int i = 0; i < 10; i++) { items.Add(new Item(i,"Item" + i,DateTime.Now.AddHours(i))); } this.radGridView1.DataSource = items; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } private void Form1_Load(object sender, EventArgs e) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB"); this.radGridView1.Columns["Date"].ExcelExportFormatString = "M/d/yyyy h:mm tt"; this.radGridView1.Columns["Date"].ExcelExportType = DisplayFormatType.Custom; GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1); spreadExporter.ExportVisualSettings = true; SpreadExportRenderer exportRenderer = new SpreadExportRenderer(); string fileName = @"..\..\exportedFile" + DateTime.Now.ToLongTimeString().Replace(":", "_") + ".xlsx"; spreadExporter.RunExport(fileName, exportRenderer); Process.Start(fileName); }
Hello, we have a RadGridview with a number column and a activated filter for this Grid. If we want to filter data by the value "123" the input in the filter textBox is shown as "321.00" (right-to-left). This is no problem by columns with text values. And at the line for a new data row the input is correct, too.
Please refer to the attached screenshot. Workaround: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("Name"); for (int i = 0; i < 5; i++) { dt.Rows.Add(i, "Item" + i); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.AllowSearchRow = true; this.radGridView1.SearchRowPosition = Telerik.WinControls.UI.SystemRowPosition.Bottom; this.radGridView1.ViewDefinition = new CustomTableViewDefition(); } public class CustomTableViewDefition : TableViewDefinition { public override IRowView CreateViewUIElement(GridViewInfo viewInfo) { return new CustomTableElement(); } } public class CustomTableElement : GridTableElement { protected override RowsContainerElement CreateViewElement() { return new CustomRowsContainerElement(); } } public class CustomRowsContainerElement : RowsContainerElement { protected override SizeF ArrangeOverride(SizeF finalSize) { float y = 0; this.TopPinnedRows.Arrange(new RectangleF(0, y, finalSize.Width, this.TopPinnedRows.DesiredSize.Height)); y += this.TopPinnedRows.DesiredSize.Height + ElementSpacing; this.ScrollableRows.Arrange(new RectangleF(0, y, finalSize.Width, this.ScrollableRows.DesiredSize.Height)); y += this.ScrollableRows.DesiredSize.Height + ElementSpacing; this.BottomPinnedRows.Arrange(new RectangleF(0, finalSize.Height - this.BottomPinnedRows.DesiredSize.Height, finalSize.Width, this.BottomPinnedRows.DesiredSize.Height)); return finalSize; } }
When you set a RadGridView's SelectionMode to GridViewSelectionMode.CellSelect and then you highlight full rows by using the row header, the SelectedRows collection is empty. Telerik support informed me this is "as expected" and that I should use "SelectedCells" collection when using the CellSelect Mode. While this is a decent workaround I don't see why SelectedRows collection can't be filled when the entire row is actually highlighted.
To reproduce: GridViewImageColumn imageColumn = new GridViewImageColumn(); imageColumn.Name = "ImageColumn"; imageColumn.FieldName = "ImageColumn"; imageColumn.HeaderText = "Picture"; radGridView1.MasterTemplate.Columns.Add(imageColumn); List<classBinding> databinding = new List<classBinding>(); for (int i = 0; i < 35000; i++) { databinding.Add(new classBinding() { ImageColumn = Properties.Resources.Alarm2, }); } radGridView1.DataSource = databinding; public class classBinding { public System.Drawing.Bitmap ImageColumn { get; set; } }
There should be a convenient and more straightforward API for accessing the TableElement of a child gridview. Currently, the API is: void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { if (e.CellElement is GridDetailViewCellElement) { ((GridDetailViewCellElement)e.CellElement).ChildTableElement.RowHeight = 50; } }
To reproduce: use the following code snippet and enter in the filter row one of the row values as it is shown in the screenshot: this.radGridView1.EnableFiltering = true; GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn("DateTimeColumn"); dateTimeColumn.Format = DateTimePickerFormat.Custom; dateTimeColumn.CustomFormat = "dd/MM/yyyy HH:mm:ss"; radGridView1.MasterTemplate.Columns.Add(dateTimeColumn); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < 10; i++) { this.radGridView1.Rows.Add(DateTime.Now.AddDays(i)); } Workaround: custom filtering: http://docs.telerik.com/devtools/winforms/gridview/filtering/custom-filtering
Please refer to the attached project. Workakround: call the BeginEdit method in the RadGridView.Click event.
Add an ExportToXlsx option into the native RadGridView exporting. It has been done for WPF (http://docs.telerik.com/devtools/wpf/controls/radgridview/export/export-xlsx) - why not WinForms. This would avoid the pain of having to implement the export using RadSpreadProcessing.
If you refresh an object set property of entity context, the RadGridView is not updated. The sample code below does not work: this.radGridView1.DataSource = entities.Countries; int maxId = (from c in entities.Countries orderby c.Id descending select c.Id).First(); Country country = new Country(); country.Id = maxId + 1; country.Name = Path.GetRandomFileName(); entities.Countries.AddObject(country); entities.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave); entities.Refresh(System.Data.Objects.RefreshMode.StoreWins, entities.Countries);
You cannot save the current row by performing the DataContext's SaveChanges method when the RadGridView is bound to IQueryable. The code should look like this to work properly: protected sealed override void BindingNavigator_SaveAction(object sender) { try { this.countriesRadGridView.EndEdit(); BindingSource bs = this.countriesRadGridView.DataSource as BindingSource; bs.EndEdit(); this.DataContext.SaveChanges(); base.FireUpdateData(); } catch (Exception Ex) { string exMessage = Ex.Message; MessageBox.Show(exMessage); } }
The control just does not appear in the destination solution.
How to handle this case: Subscribe to the CellValidating event and add logic for validation. For example: If e.Value Is Nothing Then e.Cancel = True End If Additionally you can handle the DataError event to handle cases where users are trying to submit invalid data through the grid to its data source. Finally, you can subscribe to the ContextMenuOpening event where to hide the "Clear value" item from context menu with following code snippet: For i As Integer = 0 To e.ContextMenu.Items.Count - 1 If e.ContextMenu.Items(i).Text = "Clear Value" Then e.ContextMenu.Items(i).Visibility = Telerik.WinControls.ElementVisibility.Collapsed End If Next
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] );
The PDF exporting of RadGridView does not work correctly for Arabic text. The exported result revers the Arabic text.
When a mask is set to a GridViewMaskBoxColumn and string is applied as value, the visual element will show only the string without the mask literals. E.g. mask is set to ####/# and value is set to string "11112" the view will be 11112 instead of 1111/2. Ways to achieve this: 1. Use CellFormatting. 2. Use a custom type converter: Example of a custom TypeConverter could be seen from the following feedback item: http://feedback.telerik.com/Project/154/Feedback/Details/112463-fix-radgridview-the-textmaskformat-property-of-gridviewmaskboxcolumn-is-not-ta
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", "-"); }
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: use the following code snippet and click the button twice. private DataTable GetTable01() { DataTable table = new DataTable(); table.Columns.Add("Dosage", typeof(int)); table.Columns.Add("Drug", typeof(string)); table.Columns.Add("Patient", typeof(string)); table.Columns.Add("Date", typeof(DateTime)); // Here we add five DataRows. 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 button1_Click_1(object sender, EventArgs e) { DataTable table01 = GetTable01(); radGridView1.Rows.Clear(); radGridView1.DataSource = table01; } WORKAROUND I: this.radGridView1.DataError += radGridView1_DataError; private void radGridView1_DataError(object sender, GridViewDataErrorEventArgs e) { if (e.Exception is ArgumentException && e.Exception.Message == "Cannot clear this list.") { this.radGridView1.BeginUpdate(); while (this.radGridView1.Rows.Count > 0) { this.radGridView1.Rows.RemoveAt(0); } this.radGridView1.EndUpdate(); } } WORKAROUND II: while (this.radGridView1.Rows.Count > 0) { this.radGridView1.Rows.RemoveAt(this.radGridView1.Rows.Count - 1); }
To reproduce: public Form1() { InitializeComponent(); this.radGridView1.CellFormatting+=radGridView1_CellFormatting; DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name",typeof(string)); for (int i = 0; i < 100; i++) { dt.Rows.Add(i,"Item"+i); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) { e.Row.Height = 40; } private void radButton1_Click(object sender, EventArgs e) { this.radGridView1.TableElement.ScrollToRow(this.radGridView1.Rows.Count - 1); } Workaround: instead of using the CellFormatting event to set the Row.Height, you can set the TableElement.RowHeight property.