To reproduce: Download the attached files. One contains a project with TelerikDataAccess, the other one contains the SQL script to create the database. Before starting the project notice the column with header text "column1". You will see that its expression is as follows: "Player.Person.FirstName+\",\"+Player.Person.LastName". Starting the project at this point will not produce an exception. Change the name of the column to FirstName and start the project, you will see the stack overflow exception.
To reproduce:
- Add two GridViewMultiComboBoxColumns with different number of columns to a grid.
- set AutoSizeDropDownToBestFit to true in the CellEditorInitialized event.
- Start the project and open the drop down for the first column and then for the second.
- You will notice that the second time the drop down size is not calculated properly.
Workaround:
void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
RadMultiColumnComboBoxElement el = e.ActiveEditor as RadMultiColumnComboBoxElement;
if (el != null)
{
FieldInfo propertyInfo = el.GetType().GetField("savedColumnsWidth", BindingFlags.NonPublic | BindingFlags.Instance);
propertyInfo.SetValue(el, -1);
el.AutoSizeDropDownToBestFit = true;
}
}
To reproduce:
DataTable t = new DataTable();
t.Columns.Add("timeSpan", typeof(TimeSpan));
t.Rows.Add(TimeSpan.FromHours(11));
t.Rows.Add(TimeSpan.FromHours(2));
t.Rows.Add(TimeSpan.FromHours(4));
t.Rows.Add(TimeSpan.FromMinutes(17));
radGridView1.DataSource = t;
GridViewSummaryItem summaryItem = new GridViewSummaryItem();
summaryItem.Name = "timeSpan";
summaryItem.Aggregate = GridAggregateFunction.Sum;
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
summaryRowItem.Add(summaryItem);
this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
Workaround:
CustomSummaryItem summaryItem = new CustomSummaryItem("timeSpan", "", GridAggregateFunction.Sum);
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
summaryRowItem.Add(summaryItem);
this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
public class CustomSummaryItem : GridViewSummaryItem
{
public CustomSummaryItem(string name, string formatString, GridAggregateFunction aggregate)
: base(name, formatString, aggregate)
{ }
public override object Evaluate(IHierarchicalRow row)
{
TimeSpan timeSpanSum = new TimeSpan();
foreach (GridViewRowInfo childRow in row.ChildRows)
{
timeSpanSum += (TimeSpan)childRow.Cells["timeSpan"].Value;
}
return timeSpanSum;
}
}
Use the following code snippet:
public Form1()
{
InitializeComponent();
GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("Id");
radGridView1.MasterTemplate.Columns.Add(decimalColumn);
GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn("Name");
radGridView1.MasterTemplate.Columns.Add(textBoxColumn);
GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn("CreatedOn");
radGridView1.MasterTemplate.Columns.Add(dateTimeColumn);
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
for (int i = 0; i < 10; i++)
{
radGridView1.Rows.Add(i, "Name" + i, DateTime.Now.AddDays(i));
}
radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.Disable;
}
If you copy a cell content and try to paste it to another cell of the same column, the content is pasted successfully, although the ClipboardPasteMode property is set to Disable.
To reproduce: use the following code snippet and refer to the attached sample gif file. When you enter edit mode for the first time, the editor is empty. Each next entering edit mode displays the respective text in the editor, although it is cut off.
public Form1()
{
InitializeComponent();
radGridView1.Font = new Font("Segoe UI", 18.0f);
radGridView1.CellEditorInitialized += pgGrid_CellEditorInitialized;
AddColumns();
radGridView1.DataSource = BuildDummyTable();
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
}
private void pgGrid_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
RadTextBoxEditor editor = e.ActiveEditor as RadTextBoxEditor;
if (editor != null)
{
((RadTextBoxEditorElement)editor.EditorElement).TextBoxItem.Multiline = true;
((RadTextBoxEditorElement)editor.EditorElement).Padding = new Padding(0);
}
}
private void AddColumns()
{
GridViewTextBoxColumn colA = new GridViewTextBoxColumn("colA");
radGridView1.Columns.Add(colA);
GridViewTextBoxColumn colB = new GridViewTextBoxColumn("colB");
radGridView1.Columns.Add(colB);
GridViewTextBoxColumn colC = new GridViewTextBoxColumn("colC");
radGridView1.Columns.Add(colC);
GridViewTextBoxColumn colD = new GridViewTextBoxColumn("colD");
radGridView1.Columns.Add(colD);
}
private DataTable BuildDummyTable()
{
DataTable table = new DataTable();
table.Columns.Add("colA");
table.Columns.Add("colB");
table.Columns.Add("colC");
table.Columns.Add("colD");
table.Rows.Add("value 1A", "value 1B", "value 1C", "value 1D");
table.Rows.Add("value 2A", "value 2B", "value 2C", "value 2D");
table.Rows.Add("value 3A", "value 3B", "value 3C", "value 3D");
return table;
}
To reproduce: add a RadGridView and bind it to Employees data table. 1. Group by "Title". 2. Group by "Country". 3. Group by "City". If you try to expand the "Sales Representative" group, no rows will be displayed. Please refer to the attached gif file, illustrating better the obtained behavior.
This happened multiple times. In the property builder, I tried to delete the column and Visual Studio crashed. I was able to delete other columns fine, but this particular column caused a problem. The only difference that I can see between the other columns and the one that caused the problem was the conditionalformattingobject. Once I deleted this conditionalformattingobject, I was able to delete the column without any problem.
To reproduce:
Declare the following classes:
public class Test
{
public string Name { get; set; }
public Child Child { get; set; }
}
public class Child
{
public string ChildName { get; set; }
public override string ToString()
{
return ChildName;
}
}
Add the following columns:
gridViewTextBoxColumn1.FieldName = "Name";
gridViewTextBoxColumn1.HeaderText = "column1";
gridViewTextBoxColumn1.Name = "column1";
gridViewTextBoxColumn2.FieldName = "Child";
gridViewTextBoxColumn2.HeaderText = "column2";
gridViewTextBoxColumn2.Name = "column2";
this.radGridView1.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {
gridViewTextBoxColumn1,
gridViewTextBoxColumn2});
this.radGridView1.Name = "radGridView1";
this.radGridView1.Size = new System.Drawing.Size(429, 176);
this.radGridView1.TabIndex = 0;
this.radGridView1.Text = "radGridView1";
Bind RadGridView to the following data:
var data = new List<Test>();
for (int i = 0; i < 10; i++)
{
data.Add(new Test
{
Name = "Name" + i,
Child = new Child
{
ChildName = "Child " + i
}
});
}
Export to Excel:
ExportToExcelML excelExporter = new ExportToExcelML(radGridView1);
excelExporter.RunExport(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"test.xls"));
You will notice that column2 will not have text
Workaround:
Subscribe to the ExcelCellFormatting event:
void excelExporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
{
if (e.ExcelCellElement.Data.DataItem.GetType().IsClass)
{
e.ExcelCellElement.Data.DataItem = e.ExcelCellElement.Data.DataItem.ToString();
}
}
To reproduce:
Add a RadGridView and set the Form.UseWaitCursor property to true. When the cursor is positioned inside the RadGridView the cursor is set back to default.
Workaround:
public RadForm1()
{
InitializeComponent();
radGridView1.GridBehavior = new CustomRowBehavior();
}
public class CustomRowBehavior : BaseGridBehavior
{
public override bool OnMouseMove(MouseEventArgs e)
{
Cursor cursor = this.GridControl.Cursor;
bool result = base.OnMouseMove(e);
this.GridControl.Cursor = cursor;
return result;
}
}
To reproduce: add a RadGridView with many columns so the horizontal scroll bar will be shown. Start navigating by pressing the right arrow key. You will notice that when you reach the last visible column in the current view, navigating to the next column changes the whole view and the current column is displayed at the beginning of the view. The expected behavior is that after pressing the right arrow key the horizontal scroll bar will move only one column forward.
Steps to reproduce: 1. Add a RadGridView with one column and one row to a form 2. Set the value of the only data cell in the grid to a string containing more than 32 'a' characters 3. Type 'a' in the search row. You will see an OverflowException
Workaround:
Me.RadGridView1.Columns("ProductName").TextAlignment = ContentAlignment.MiddleRight
To reproduce: use the following code snippet:
public Form1()
{
InitializeComponent();
GridViewComboBoxColumn supplierColumn = new GridViewComboBoxColumn("SupplierID");
supplierColumn.DataSource = this.suppliersBindingSource;
supplierColumn.ValueMember = "SupplierID";
supplierColumn.DisplayMember = "ContactName";
supplierColumn.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
this.radGridView1.Columns.Add(supplierColumn);
this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
}
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
if (editor != null)
{
RadDropDownListEditorElement el = editor.EditorElement as RadDropDownListEditorElement;
el.SelectedIndexChanging -= el_SelectedIndexChanging;
el.SelectedIndexChanging += el_SelectedIndexChanging;
el.SelectedIndexChanged -= el_SelectedIndexChanged;
el.SelectedIndexChanged += el_SelectedIndexChanged;
}
}
private void el_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
Console.WriteLine("Changed");
}
private void el_SelectedIndexChanging(object sender, Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
{
e.Cancel = true;
}
private void Form1_Load(object sender, EventArgs e)
{
this.suppliersTableAdapter.Fill(this.nwindDataSet.Suppliers);
}
When the editor is initialized you will notice that the editor's value can be changed by using the mouse wheel no matter that the SelectedIndexChanging event is cancelled.
To reproduce:
- Enable the search row in the grid.
- Enter some text in the search text box in order to mark some rows.
- Refresh the master template.
- Notice that the text is cleared, but the formatting remains.
Workaround, use the following custom cell:
class MyGridSearchCellElement : GridSearchCellElement
{
public MyGridSearchCellElement(GridViewColumn column, GridRowElement row)
:base (column, row)
{
}
bool performSearch = true;
protected override void SyncLabelText()
{
//base.SyncLabelText();
GridViewSearchRowInfo searchRow = this.RowInfo as GridViewSearchRowInfo;
if (searchRow == null)
{
return;
}
performSearch = false;
string searchCriteria = typeof(GridViewSearchRowInfo).GetField("searchCriteria", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(searchRow).ToString();
if (string.IsNullOrEmpty(searchCriteria))
{
this.SearchTextBox.Text = String.Empty;
this.SearchTextBox.SearchInfoLabel.Text = String.Empty;
}
else
{
this.SearchTextBox.Text = searchCriteria;
this.SearchTextBox.SearchInfoLabel.Text = string.Format("{0} {1} {2}", searchRow.CurrentResultIndex + 1, Telerik.WinControls.UI.Localization.RadGridLocalizationProvider.CurrentProvider.GetLocalizedString(Telerik.WinControls.UI.Localization.RadGridStringId.SearchRowResultsOfLabel), searchRow.CurrentSearchResultsCount);
}
performSearch = true;
}
protected override void Search()
{
if (!performSearch)
{
return;
}
base.Search();
}
}
To put it in action, use the CreateCell event of RadGridView:
void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
if (e.CellType == typeof( GridSearchCellElement))
{
e.CellElement = new MyGridSearchCellElement(e.Column, e.Row);
}
}
To reproduce: use the following code snippet and follow the steps in the attached gif file.
private void Form1_Load(object sender, EventArgs e)
{
this.order_DetailsTableAdapter.Fill(this.nwindDataSet.Order_Details);
this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
radGridView1.AutoGenerateHierarchy = true;
radGridView1.DataSource = this.nwindDataSet;
radGridView1.DataMember = "Orders";
radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.MasterTemplate.Templates.First().AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.EnablePaging = true;
radGridView1.MasterTemplate.Templates.First().EnableFiltering = true;
FilterDescriptor fd = new FilterDescriptor();
fd.PropertyName = "UnitPrice";
fd.Operator = FilterOperator.IsGreaterThan;
fd.Value = 40;
radGridView1.MasterTemplate.Templates.First().FilterDescriptors.Add(fd);
radGridView1.MouseDown += radGridView1_MouseDown;
}
private void radGridView1_MouseDown(object sender, MouseEventArgs e)
{
GridDetailViewCellElement detailCell = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDetailViewCellElement;
if (detailCell != null)
{
radGridView1.MasterTemplate.Templates.First().FilterDescriptors.Clear();
}
}
Workaround:
private void radGridView1_MouseDown(object sender, MouseEventArgs e)
{
GridDetailViewCellElement detailCell = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridDetailViewCellElement;
if (detailCell != null)
{
radGridView1.MasterTemplate.Templates.First().FilterDescriptors.Clear();
GridViewHierarchyRowInfo hierarchyRow = (GridViewHierarchyRowInfo)((GridViewDetailsRowInfo)detailCell.RowInfo).Owner;
hierarchyRow.IsExpanded = ! hierarchyRow.IsExpanded;
hierarchyRow.IsExpanded = ! hierarchyRow.IsExpanded;
hierarchyRow.ChildRows.Last().EnsureVisible();
}
}
Workaround:
private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
GridBrowseEditor browseEditor = e.ActiveEditor as GridBrowseEditor;
if (browseEditor!=null)
{
browseEditor.EditorElement.MinSize = new Size(0,18);
GridBrowseEditorElement el = browseEditor.EditorElement as GridBrowseEditorElement;
el.TextBoxItem.TextBoxControl.MinimumSize = new Size(0, 13);
}
}