To reproduce use this code:
public partial class Form1 : Form
{
RadGridView radGridView1 = new RadGridView();
public Form1()
{
InitializeComponent();
this.Controls.Add(this.radGridView1);
this.radGridView1.Dock = DockStyle.Fill;
this.radGridView1.AutoGenerateColumns = false;
this.radGridView1.TableElement.RowHeight = 30;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.AddNewRowPosition = SystemRowPosition.Bottom;
this.radGridView1.EnterKeyMode = RadGridViewEnterKeyMode.EnterMovesToNextCell;
this.radGridView1.NewRowEnterKeyMode = RadGridViewNewRowEnterKeyMode.EnterMovesToNextCell;
this.radGridView1.BeginEditMode = Telerik.WinControls.RadGridViewBeginEditMode.BeginEditOnKeystrokeOrF2;
this.radGridView1.EnableGrouping = false;
this.radGridView1.EnableAlternatingRowColor = true;
this.radGridView1.AllowAddNewRow = true;
this.radGridView1.AllowEditRow = true;
this.radGridView1.AllowDeleteRow = true;
this.radGridView1.EnableFiltering = true;
this.radGridView1.EnableSorting = true;
ArrayList arrayList = new ArrayList();
arrayList.Add(new Person() { Name = "Jack", Family = "J..." });
arrayList.Add(new Person() { Name = "Bob", Family = "B..." });
arrayList.Add(new Person() { Name = "Dani", Family = "D..." });
radGridView1.Columns.Add("ColName", "Name", "Name");
radGridView1.Columns.Add("ColFamily", "Family", "Family");
radGridView1.DataSource = arrayList;
this.radGridView1.CellValidating +=radGridView1_CellValidating;
}
private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e)
{
GridViewDataColumn column = e.Column as GridViewDataColumn;
if ((e.Row is GridViewDataRowInfo || e.Row is GridViewNewRowInfo) && column != null
&& (column.Name == "ColName"))
{
if (e.Value == null || ((string)e.Value).Trim() == "") if (string.IsNullOrEmpty
((string)e.Value) || ((string)e.Value).Trim() == string.Empty || string.IsNullOrWhiteSpace
((string)e.Value))
{
if (e.ActiveEditor != null)
{
MessageBox.Show("Please enter your name");
e.Cancel = true;
}
}
}
}
}
public class Person
{
private string name;
private string family;
public string Name
{
get { return name; }
set { name = value; }
}
public string Family
{
get { return family; }
set { family = value; }
}
}
Try to add a new row by clicking the cell of the first column and leaving it empty. You will see the messagebox twice.
Workaround:
public class MyGridRowBehavior : GridNewRowBehavior
{
protected override bool ProcessEnterKey(KeyEventArgs keys)
{
GridViewNewRowInfo newRowInfo = (GridViewNewRowInfo)this.GridViewElement.CurrentRow;
if (this.GridViewElement.NewRowEnterKeyMode == RadGridViewNewRowEnterKeyMode.EnterMovesToNextCell)
{
bool editorClosed = !this.IsInEditMode;
if (this.IsInEditMode)
{
if (this.IsOnLastCell())
{
if (newRowInfo != null)
{
newRowInfo.GetType().GetMethod("DeferUserAddedRow", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(newRowInfo, null);
}
editorClosed = GridViewElement.EndEdit();
}
else
{
editorClosed = GridViewElement.CloseEditor();
}
}
if (editorClosed)
{
this.Navigator.SelectNextColumn();
this.GridViewElement.BeginEdit();
}
if (this.IsInEditMode && this.GridViewElement.CurrentRow is GridViewNewRowInfo &&
this.GridViewElement.BeginEditMode != RadGridViewBeginEditMode.BeginEditProgrammatically)
{
return this.GridViewElement.BeginEdit();
}
if (newRowInfo != null)
{
newRowInfo.GetType().GetMethod("RaiseUserAddedRow", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(newRowInfo, null);
}
return false;
}
return base.ProcessEnterKey(keys);
}
}
((BaseGridBehavior)this.radGridView1.GridBehavior).UnregisterBehavior(typeof(GridViewNewRowInfo));
((BaseGridBehavior)this.radGridView1.GridBehavior).RegisterBehavior(typeof(GridViewNewRowInfo), new MyGridRowBehavior());
To reproduce:
this.grid.Columns.Add(new GridViewDecimalColumn("col"));
for (int i = 0; i < 5; i++)
{
this.grid.Rows.Add(i);
}
GridViewSummaryItem stDev = new GridViewSummaryItem()
{
Name = "col",
Aggregate = GridAggregateFunction.Var // or GridAggregateFunction.StDev
};
var row = new GridViewSummaryRowItem();
row.Add(stDev);
this.grid.SummaryRowsTop.Add(row);
This will throw an exception.
To reproduce: Create a project with RadGridView, add some rows, make sure you have space to perform panning. Pan up and down, exception should occur. Workaround :
radgridView1.ViewDefinition = new MyTableViewDefinition();
public class MyTableViewDefinition : TableViewDefinition
{
public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
{
return new MyGridTableElement();
}
}
public class MyGridTableElement : GridTableElement
{
protected override void OnPanGesture(Telerik.WinControls.PanGestureEventArgs args)
{
//base.OnPanGesture(args) -> you can stop touch support by also not calling the base and leaving this method empty
if (args.IsBegin &&
(this.RowScroller.Scrollbar.ControlBoundingRectangle.Contains(args.Location) ||
this.ColumnScroller.Scrollbar.ControlBoundingRectangle.Contains(args.Location) ||
this.ViewElement.TopPinnedRows.ControlBoundingRectangle.Contains(args.Location)))
{
return;
}
bool containsCurrent = (this.GridViewElement.CurrentRow == null && this.GridViewElement.Template == this.ViewTemplate);
if (!containsCurrent)
{
foreach (IRowView child in this.GridViewElement.GetRowViews(this.GridViewElement.CurrentRow.ViewInfo))
{
containsCurrent |= (child == this);
}
}
if (!containsCurrent)
{
return;
}
this.GridViewElement.EndEdit();
int newVerticalValue = this.RowScroller.Scrollbar.Value - args.Offset.Height;
if (newVerticalValue > this.RowScroller.Scrollbar.Maximum - this.RowScroller.Scrollbar.LargeChange + 1)
{
newVerticalValue = this.RowScroller.Scrollbar.Maximum - this.RowScroller.Scrollbar.LargeChange + 1;
}
if (newVerticalValue < this.RowScroller.Scrollbar.Minimum)
{
newVerticalValue = this.RowScroller.Scrollbar.Minimum;
}
RadScrollBarElement rowScrollbar = this.RowScroller.Scrollbar;
if (newVerticalValue > rowScrollbar.Maximum)
{
newVerticalValue = rowScrollbar.Maximum;
}
else if (newVerticalValue < 0)
{
newVerticalValue = 0;
}
this.RowScroller.Scrollbar.Value = newVerticalValue;
int newHorizontalValue = this.ColumnScroller.Scrollbar.Value - args.Offset.Width;
if (newHorizontalValue > this.ColumnScroller.Scrollbar.Maximum - this.ColumnScroller.Scrollbar.LargeChange + 1)
{
newHorizontalValue = this.ColumnScroller.Scrollbar.Maximum - this.ColumnScroller.Scrollbar.LargeChange + 1;
}
if (newHorizontalValue < this.ColumnScroller.Scrollbar.Minimum)
{
newHorizontalValue = this.ColumnScroller.Scrollbar.Minimum;
}
RadScrollBarElement columnScrollBar = this.ColumnScroller.Scrollbar;
if (newHorizontalValue > columnScrollBar.Maximum)
{
newHorizontalValue = columnScrollBar.Maximum;
}
else if (newHorizontalValue < 0)
{
newHorizontalValue = 0;
}
this.ColumnScroller.Scrollbar.Value = newHorizontalValue;
args.Handled = true;
}
}
To reproduce:
- generate the hierarchy using the following code:
radGridView1.SelectionMode = GridViewSelectionMode.CellSelect;
radGridView1.MultiSelect = true;
radGridView1.ClipboardCopyMode = GridViewClipboardCopyMode.EnableWithoutHeaderText;
radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.Enable;
radGridView1.AutoGenerateColumns = true;
radGridView1.CellValueChanged += grid_CellValueChanged;
radGridView1.EnableSorting = true;
radGridView1.AllowMultiColumnSorting = true;
radGridView1.ShowGroupPanel = true;
radGridView1.EnableFiltering = true;
radGridView1.ShowFilteringRow = false;
radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
for (int i = 0; i < 10; i++)
{
dt1.Columns.Add("Column" + i);
dt2.Columns.Add("Column" + i);
}
var temp = new GridViewTemplate();
temp.AutoGenerateColumns = true;
radGridView1.Templates.Add(temp);
var rel = new GridViewRelation(radGridView1.MasterTemplate, temp);
rel.ChildColumnNames.Add("Column1");
rel.ParentColumnNames.Add("Column1");
radGridView1.Relations.Add(rel);
radGridView1.MasterTemplate.DataSource = dt1;
dt1.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(3, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(4, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(5, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
temp.DataSource = dt2;
1. Run the project with the generated hierarchy
2. Select second cell in first row.
3. Expand first row and select fifth cell in first child row.
4. Hold Shift-Key and press down arrow after that right arrow twice.
selection will be incorrect
To reproduce:
Generate the hierarchy with the following code:
radGridView1.SelectionMode = GridViewSelectionMode.CellSelect;
radGridView1.MultiSelect = true;
radGridView1.ClipboardCopyMode = GridViewClipboardCopyMode.EnableWithoutHeaderText;
radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.Enable;
radGridView1.AutoGenerateColumns = true;
radGridView1.CellValueChanged += grid_CellValueChanged;
//radGridView1.ViewCellFormatting += GridCellFormatting;
//radGridView1.RowFormatting += grid_RowFormatting;
radGridView1.EnableSorting = true;
//radGridView1.MasterTemplate.EnableCustomSorting = true;
radGridView1.AllowMultiColumnSorting = true;
radGridView1.ShowGroupPanel = true;
radGridView1.EnableFiltering = true;
radGridView1.ShowFilteringRow = false;
radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
DataTable dt1 = new DataTable();
dt1.Columns.Add("Column1");
dt1.Columns.Add("Column2");
dt1.Columns.Add("Column3");
dt1.Columns.Add("Column4");
dt1.Columns.Add("Column5");
dt1.Columns.Add("Column6");
dt1.Columns.Add("Column7");
dt1.Columns.Add("Column8");
dt1.Columns.Add("Column9");
dt1.Columns.Add("Column10");
DataTable dt2 = new DataTable();
dt2.Columns.Add("Column1");
dt2.Columns.Add("Column2");
dt2.Columns.Add("Column3");
dt2.Columns.Add("Column4");
dt2.Columns.Add("Column5");
dt2.Columns.Add("Column6");
dt2.Columns.Add("Column7");
dt2.Columns.Add("Column8");
dt2.Columns.Add("Column9");
var temp = new GridViewTemplate();
temp.AutoGenerateColumns = true;
radGridView1.Templates.Add(temp);
var rel = new GridViewRelation(radGridView1.MasterTemplate, temp);
rel.ChildColumnNames.Add("Column1");
rel.ParentColumnNames.Add("Column1");
radGridView1.Relations.Add(rel);
radGridView1.MasterTemplate.DataSource = dt1;
dt1.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(3, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(4, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(5, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
temp.DataSource = dt2;
1. Run the project with the generated hierarchy
2. Select Last cell in first row. (there is no "Column9" in Child Template)
3. Expand first row and select any cell in first child row.
4. Hold Shift-Key and press down arrow or up arrow until you receive a NullReferenceException.
To reproduce:
Generate the hierarchy with the following code:
radGridView1.SelectionMode = GridViewSelectionMode.CellSelect;
radGridView1.MultiSelect = true;
radGridView1.ClipboardCopyMode = GridViewClipboardCopyMode.EnableWithoutHeaderText;
radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.Enable;
radGridView1.AutoGenerateColumns = true;
radGridView1.CellValueChanged += grid_CellValueChanged;
//radGridView1.ViewCellFormatting += GridCellFormatting;
//radGridView1.RowFormatting += grid_RowFormatting;
radGridView1.EnableSorting = true;
//radGridView1.MasterTemplate.EnableCustomSorting = true;
radGridView1.AllowMultiColumnSorting = true;
radGridView1.ShowGroupPanel = true;
radGridView1.EnableFiltering = true;
radGridView1.ShowFilteringRow = false;
radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
DataTable dt1 = new DataTable();
dt1.Columns.Add("Column1");
dt1.Columns.Add("Column2");
dt1.Columns.Add("Column3");
dt1.Columns.Add("Column4");
dt1.Columns.Add("Column5");
dt1.Columns.Add("Column6");
dt1.Columns.Add("Column7");
dt1.Columns.Add("Column8");
dt1.Columns.Add("Column9");
dt1.Columns.Add("Column10");
DataTable dt2 = new DataTable();
dt2.Columns.Add("Column1");
dt2.Columns.Add("Column2");
dt2.Columns.Add("Column3");
dt2.Columns.Add("Column4");
dt2.Columns.Add("Column5");
dt2.Columns.Add("Column6");
dt2.Columns.Add("Column7");
dt2.Columns.Add("Column8");
dt2.Columns.Add("Column9");
var temp = new GridViewTemplate();
temp.AutoGenerateColumns = true;
radGridView1.Templates.Add(temp);
var rel = new GridViewRelation(radGridView1.MasterTemplate, temp);
rel.ChildColumnNames.Add("Column1");
rel.ParentColumnNames.Add("Column1");
radGridView1.Relations.Add(rel);
radGridView1.MasterTemplate.DataSource = dt1;
dt1.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(3, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(4, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt1.Rows.Add(5, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6, 9);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(1, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
dt2.Rows.Add(2, "sdf", "sdfsfqwert", 1, 2, 3, 4, 7, 6);
temp.DataSource = dt2;
1. Run the project with the generated hierarchy
2. Select second cell in first row.
3. Expand first row and select 3 cells in fifth column by mouse drag
4. Right click on selection and "Copy" or press Ctrl+C.
5. Try to Paste the data into 7-th column.
6. The data is pasted in the second column
To reproduce: Create a project with RadGridView, add some rows, make sure you have space to perform panning. Exception should occur. Workaround: this.myGridView.ViewDefinition = new MyTableViewDefinition(); public class MyTableViewDefinition : TableViewDefinition { public override IRowView CreateViewUIElement(GridViewInfo viewInfo) { return new MyGridTableElement(); } } public class MyGridTableElement : GridTableElement { protected override void OnPanGesture(Telerik.WinControls.PanGestureEventArgs args) { if (args.IsBegin && (this.RowScroller.Scrollbar.ControlBoundingRectangle.Contains(args.Location) || this.ColumnScroller.Scrollbar.ControlBoundingRectangle.Contains(args.Location) || this.ViewElement.TopPinnedRows.ControlBoundingRectangle.Contains(args.Location))) { return; } bool containsCurrent = (this.GridViewElement.CurrentRow == null && this.GridViewElement.Template == this.ViewTemplate); if (!containsCurrent) { foreach (IRowView child in this.GridViewElement.GetRowViews(this.GridViewElement.CurrentRow.ViewInfo)) { containsCurrent |= (child == this); } } if (!containsCurrent) { return; } this.GridViewElement.EndEdit(); int newVerticalValue = this.RowScroller.Scrollbar.Value - args.Offset.Height; if (newVerticalValue > this.RowScroller.Scrollbar.Maximum - this.RowScroller.Scrollbar.LargeChange + 1) { newVerticalValue = this.RowScroller.Scrollbar.Maximum - this.RowScroller.Scrollbar.LargeChange + 1; } if (newVerticalValue < this.RowScroller.Scrollbar.Minimum) { newVerticalValue = this.RowScroller.Scrollbar.Minimum; } this.RowScroller.Scrollbar.Value = newVerticalValue; int newHorizontalValue = this.ColumnScroller.Scrollbar.Value - args.Offset.Width; if (newHorizontalValue > this.ColumnScroller.Scrollbar.Maximum - this.ColumnScroller.Scrollbar.LargeChange + 1) { newHorizontalValue = this.ColumnScroller.Scrollbar.Maximum - this.ColumnScroller.Scrollbar.LargeChange + 1; } if (newHorizontalValue < this.ColumnScroller.Scrollbar.Minimum) { newHorizontalValue = this.ColumnScroller.Scrollbar.Minimum; } RadScrollBarElement scrollbar = this.ColumnScroller.Scrollbar; if (newHorizontalValue > scrollbar.Maximum) { newHorizontalValue = scrollbar.Maximum; } else if (newHorizontalValue < 0) { newHorizontalValue = 0; } this.ColumnScroller.Scrollbar.Value = newHorizontalValue; args.Handled = true; } }
1. Create a new project with RadGridView 2. Bind the grid to a data source containing 200k rows 3. Allow the multiple row selection (MultiSelect = true) 4. Run the application 5. Select all rows (Ctrl+A) 6. Scroll down 7.Try to select another row
There is an exception when the new row is current and clicking on a column header. Steps to reproduce: 1. click to add a row but don't make a selection 2. click on the row header
1. Create a new project with RadGridView 2. Create and add a column which uses editor based on RadMultiColumnComboBox 3. Run the project and try to filter by this column
1. Create a new project with RadGridView. 2. Bind it to a data source with two columns and make the first one read only. 3. Handle the CellValidating event and add a condition to validate the second column. 4. Run the project and enter invalid value in second column. 5. Now enter a correct value and press Tab key. You will be navigated to a wrong row.
1. Create a new project with RadGridView. 2. Set AutoSizeRows to true and WrapText in one of the columns to true. 3. Set the ApplicationThemeName to Aqua. 4. Set EnableFiltering to true. 5. Run the application and filter by the first column, the filtering row resizes correctly. Now filter the column where WrapText is set to true. It will not resize correctly.
This method should return true if successful.
1. Create RadGridView with hierarchy. 2. Set UseScrollbarsInHierarchy property to true. 3. Handle the CellDoubleClick event. 4. Run the project, open a child view and double click on its scrollbar. The CellDoubleClick event will fire which is wrong.
1. Create a new project with RadGridView. 2. Make all columns read only. 3. Use Ctrl+x, +v and +c key combinations.
1. Create a new project and add RadGridView. 2. Bind a hierarchy. 3. Set MultiSelect property to true. 4. Replace default GridViewHierarchyRowInfo class with a custom one and override its SetBooleanProperty method. 5. Change child rows IsSelected property when parent row IsSelected property changes. 6. Run the project and try to select rows with the mouse.
1. Create a new project with RadGridView. 2. Add a column containing TimeSpan values. 3. Add a method which exports RadGridView in ExcelML. 4. Run the project and export the grid.
1. Create a project with RadGridView. 2. Group by some column. 3. Set the MultiSelect option to true. 4. When handling the CellValueChanged event change the value for all selected rows. 5. Run the project and filter by some column. 6. Select some rows and edit a value of a cell from the filtered column. 7. Repeat the action.
1. Create a new project with RadGridView and setup 2 level hierarchy.
2. Add a checkbox column at the second level and set its pinned state to Left.
3. Run the application.
4. Expand the first row and click on the checkbox. Be sure that RadGridView contains enough columns in its child view to show horizontal scrollbar.
Workaround: create a custom view definition
public class CustomTableViewDefinition : TableViewDefinition
{
public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
{
CustomTableElement table = new CustomTableElement();
return table;
}
}
public class CustomTableElement : GridTableElement
{
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridTableElement);
}
}
public override bool EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
{
if (column.IsPinned)
{
return true;
}
return base.EnsureCellVisible(rowInfo, column);
}
}
Set the view definition to the child template by using the ViewDefinition property
this.gridViewDemoData.Templates[0].ViewDefinition = new CustomTableViewDefinition();
1. Create a new project with RadGridView and bind it. 2. Setup 2 level grouping. 3. Add top summary row. 4. Set the ShowParentGroupSummaries property to true. 5. Run the project and expand a group. 6. Edit a cell from a column that has a summary item attached. 7. Notice that the parent summary row is not updated properly.