To reproduce: use the following code snippet and follow the steps illustrated on the attached gif file:
private void Form1_Load(object sender, EventArgs e)
{
this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
this.radGridView1.DataSource = this.customersBindingSource;
this.radGridView1.BestFitColumns(BestFitColumnMode.AllCells);
ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
view.ColumnGroups.Add(new GridViewColumnGroup("Customer Contact"));
view.ColumnGroups.Add(new GridViewColumnGroup("Details"));
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Address"));
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Contact"));
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["CompanyName"]);
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactName"]);
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactTitle"]);
view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Address"]);
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["City"]);
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Country"]);
view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Phone"]);
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Fax"]);
radGridView1.ViewDefinition = view;
}
Sometimes the incorrect behavior is obtained immediately after you drop the column, but you need to scroll the horizontal scroll-bar to replicate it.
Workaround:
RadGridViewDragDropService svc = this.radGridView1.GridViewElement.GetService<RadGridViewDragDropService>();
svc.Stopped += svc_Stopped;
private void svc_Stopped(object sender, EventArgs e)
{
int horizontalScrollvalue = this.radGridView1.TableElement.HScrollBar.Value;
this.radGridView1.MasterTemplate.Refresh();
this.radGridView1.TableElement.HScrollBar.Value = horizontalScrollvalue;
}
Workaround:
Subscribe to CellFormatting event:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
if (e.CellElement is GridCheckBoxCellElement)
{
e.CellElement.ToolTipText = "ErrorMessage for CheckBoxColumn";
e.CellElement.Children[0].ToolTipText = "ErrorMessage for CheckBoxColumn";
e.CellElement.Children[0].Children[0].ToolTipText = "ErrorMessage for CheckBoxColumn";
}
}
To reproduce:
this.radGridView1.MultiSelect = true;
Please refer to the attached gif file illustrating better the behavior.
1. Select a row and filter the grid in a way to keep the selected row visible.
2. The first row in the ChildRows collection is selected.
3. Clear the filter. The selection is stored and only one row is selected.
4. Repeat the above steps, but perform such filtering that hides the selected cell. When you clear the filter, two rows are selected instead of one.
Workaround:
private void radGridView1_FilterChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{
this.radGridView1.ClearSelection();
if (this.radGridView1.CurrentCell!=null)
{
this.radGridView1.CurrentCell.IsSelected = true;
this.radGridView1.CurrentRow.IsSelected = true;
this.radGridView1.GridNavigator.Select(this.radGridView1.CurrentRow, this.radGridView1.CurrentColumn);
}
}
To reproduce:
string fileName = @"..\..\..\exported" + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + ".xlsx";
SpreadExport spreadExporter = new SpreadExport(radGridView1);
spreadExporter.ExportVisualSettings = false;
spreadExporter.RunExport(fileName);
Workaround:
spreadExporter.WorkbookCreated += spreadExporter_WorkbookCreated;
private void spreadExporter_WorkbookCreated(object sender, WorkbookCreatedEventArgs e)
{
Telerik.Windows.Documents.Spreadsheet.PropertySystem.CellStyle defaultStyle = e.Workbook.Styles.Add("DefaultStyle");
defaultStyle.FontSize = Telerik.Windows.Documents.Spreadsheet.Utilities.UnitHelper.PointToDip(11);
Telerik.Windows.Documents.Spreadsheet.Model.Worksheet sheet = e.Workbook.Worksheets.First();
sheet.Cells[0, 0, sheet.UsedCellRange.RowCount, sheet.UsedCellRange.ColumnCount].SetStyleName("DefaultStyle");
sheet.Columns[sheet.UsedCellRange].AutoFitWidth();
}
Use the following code snippet and follow the illustrated steps on the attached gif file:
private void Form1_Load(object sender, EventArgs e)
{
this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
this.radGridView1.DataSource = this.customersBindingSource;
this.radGridView1.BestFitColumns(BestFitColumnMode.AllCells);
ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
view.ColumnGroups.Add(new GridViewColumnGroup("Customer Contact"));
view.ColumnGroups.Add(new GridViewColumnGroup("Details"));
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Address"));
view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Contact"));
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["CompanyName"]);
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactName"]);
view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["ContactTitle"]);
view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Address"]);
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["City"]);
view.ColumnGroups[1].Groups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Country"]);
view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Phone"]);
view.ColumnGroups[1].Groups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Fax"]);
radGridView1.ViewDefinition = view;
}
To reproduce:
public RadForm1()
{
InitializeComponent();
DataTable master = new DataTable();
master.Columns.Add("ID", typeof(int));
master.Columns.Add("F_ID", typeof(int));
master.Columns.Add("test", typeof(string));
DataTable child = new DataTable();
child.Columns.Add("F_ID", typeof(int));
child.Columns.Add("test", typeof(string));
child.Columns.Add("CheckBox", typeof(bool));
for (int i = 0; i < 10; i++)
{
master.Rows.Add(i, i , "Row " + i);
child.Rows.Add(i , "Child " + i, true);
}
radGridView1.DataSource = master;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = child;
radGridView1.MasterTemplate.Templates.Add(template);
GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "Test";
relation.ParentColumnNames.Add("F_ID");
relation.ChildColumnNames.Add("F_ID");
radGridView1.Relations.Add(relation);
this.Load += RadForm1_Load;
}
void RadForm1_Load(object sender, EventArgs e)
{
GridViewCheckBoxColumn col = radGridView1.MasterTemplate.Templates[0].Columns[2] as GridViewCheckBoxColumn;
col.EnableHeaderCheckBox = true;
}
- Expand some rows and click on header check box.
To reproduce:
this.radGridView1.MultiSelect = true;
GroupDescriptor descriptor1 = new GroupDescriptor();
descriptor1.GroupNames.Add("ProductId", ListSortDirection.Ascending );
this.radGridView1.GroupDescriptors.Add(descriptor1);
Please refer to the attached gif file.
Workaround - hide the expander items if space is not enough:
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
GridDataCellElement cell = e.CellElement as GridDataCellElement;
if (cell != null && cell.SelfReferenceLayout != null)
{
foreach (RadElement element in cell.SelfReferenceLayout.StackLayoutElement.Children)
{
GridExpanderItem expanderItem = element as GridExpanderItem;
if (expanderItem != null)
{
if (cell.ColumnInfo.Width < cell.SelfReferenceLayout.StackLayoutElement.Size.Width)
{
expanderItem.Opacity = 0;
}
else
{
expanderItem.Opacity = 1;
}
}
}
}
}
To reproduce:
List<Coordinate> coordinates_ = new List<Coordinate>();
public Form1()
{
InitializeComponent();
for (int i = 0; i < 10; i++)
{
coordinates_.Add(new Coordinate(i * 0.25, i * 0.33, i * 0.46));
}
this.radGridView1.AutoGenerateColumns = false;
string mask = "F2";
this.radGridView1.Columns.Add(CreateDecimalColumn("X", "X", mask));
this.radGridView1.Columns.Add(CreateDecimalColumn("Y", "Y", mask));
this.radGridView1.Columns.Add(CreateDecimalColumn("Z", "Z", mask));
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
SetRows();
}
GridViewDataColumn CreateDecimalColumn(string name, string headertext, string mask)
{
var format = "{0:" + mask + "}";
return new GridViewMaskBoxColumn()
{
Name = name,
HeaderText = headertext,
MinWidth = 50,
MaskType = MaskType.Numeric,
Mask = mask,
FormatString = format,
DataType = typeof(double),
TextAlignment = ContentAlignment.MiddleRight
};
}
void SetRows()
{
foreach (var c in coordinates_)
{
var ri = radGridView1.Rows.AddNew();
ri.Cells["X"].Value = c.X;
ri.Cells["Y"].Value = c.Y;
ri.Cells["Z"].Value = c.Z;
}
}
public class Coordinate
{
public double X { get; set; }
public double Y { get; set; }
public double Z { get; set; }
public Coordinate(double x, double y, double z)
{
this.X = x;
this.Y = y;
this.Z = z;
}
}
Workaround:
private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
if (e.EditorType==typeof(RadMaskedEditBoxEditor))
{
e.Editor = new RadMaskedEditBoxEditor();
}
}
To reproduce:
public Form1()
{
InitializeComponent();
GridViewDecimalColumn idColumn = new GridViewDecimalColumn("ID");
radGridView1.MasterTemplate.Columns.Add(idColumn);
GridViewDecimalColumn parentIdColumn = new GridViewDecimalColumn("ParentID");
radGridView1.MasterTemplate.Columns.Add(parentIdColumn);
GridViewTextBoxColumn nameColumn = new GridViewTextBoxColumn("Name");
radGridView1.MasterTemplate.Columns.Add(nameColumn);
GridViewTextBoxColumn addressColumn = new GridViewTextBoxColumn("Address");
radGridView1.MasterTemplate.Columns.Add(addressColumn);
GridViewTextBoxColumn typeColumn = new GridViewTextBoxColumn("Type");
radGridView1.MasterTemplate.Columns.Add(typeColumn);
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID");
AddNewRow("1", null, "Project", "USA", "Project");
AddNewRow("2", "1", "Site 1", "New York", "Site");
AddNewRow("3", "2", "Bldg 1", "Road 1", "Building");
AddNewRow("4", "1", "Site 2", "New York", "Site");
AddNewRow("5", "4", "Bldg 2", "Road 2", "Building");
AddNewRow("20", "3", "Floor 1", "Road 20", "Floor");
AddNewRow("30", "3", "Floor 2", "Road 30", "Floor");
AddNewRow("40", "3", "Floor 3", "Road 40", "Floor");
}
public void AddNewRow(
params object[] values)
{
if (values.Length != radGridView1.Columns.Count)
return;
GridViewRowInfo newRow = radGridView1.Rows.AddNew();
newRow.Cells[0].Value = values[0];
newRow.Cells[1].Value = values[1];
newRow.Cells[2].Value = values[2];
newRow.Cells[3].Value = values[3];
newRow.Cells[4].Value = values[4];
}
When you run the project you will notice that the last row is missing (AddNewRow("40", "3", "Floor 3", "Road 40", "Floor");). Please refer to the attached screenshots.
Workaround: use the Rows.Add(params) method instead:
To reproduce: - Add a column to the grid and try to set its IsPinned property to true.
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;
}
}
One should be able to replace the exported file if such exists.
To reproduce:
- Populate the grid with some double values.
- Change the culture to Dutch(Belgian)
- Export the grid
Workaround:
void spreadExporter_CellFormatting(object sender, Telerik.WinControls.UI.Export.SpreadExport.CellFormattingEventArgs e)
{
if (e.GridColumnIndex == 0 && e.GridCellInfo.Value != string.Empty)
{
CellValueFormat cvf = new CellValueFormat("0,00");
e.CellSelection.SetFormat(cvf);
e.CellSelection.SetValue(((double)e.GridCellInfo.Value));
}
}
To reproduce: use the following code snippet and perform the steps illustrated on the attached gif file:
http://www.telerik.com/help/winforms/gridview-filtering-excel-like-filtering.html
public Form1()
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("Name", typeof(string));
DateTime date;
for (int i = 0; i < 5; i++)
{
date = DateTime.Today.AddDays(i);
dt.Rows.Add(i,date, "Item." + i );
date = date.AddHours(2);
dt.Rows.Add(i,date ,"Item." + i + ".2" );
date = date.AddMonths(i);
dt.Rows.Add(i,date, "Item." + i + ".2");
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowHeaderCellButtons = true;
((GridViewDateTimeColumn)this.radGridView1.Columns[1]).FilteringMode = GridViewTimeFilteringMode.Date;
this.radGridView1.FilterPopupRequired += radGridView1_FilterPopupRequired;
}
private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
{
if (e.Column.Name == "Date")
{
e.FilterPopup = new RadListFilterPopup(e.Column, true);
}
}
Workaround:
RadListFilterPopup popup;
private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
{
if (e.Column.Name == "Date")
{
if (popup == null)
{
popup = new RadListFilterPopup(e.Column, true);
}
e.FilterPopup = popup;
}
}
To reproduce:
private void Form1_Load(object sender, EventArgs e)
{
this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
this.radGridView1.DataSource = this.customersBindingSource;
this.radGridView1.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.AllCells);
this.radGridView1.AllowSearchRow = true;
}
Workaround:
private void Form1_Load(object sender, EventArgs e)
{
RadDragDropService svc = this.radGridView1.GridViewElement.GetService<RadDragDropService>();
svc.PreviewDragDrop += svc_PreviewDragDrop;
}
private void svc_PreviewDragDrop(object sender, RadDropEventArgs e)
{
GridViewSearchRowInfo.Cancel = true;
}