To reproduce:
public Form1()
{
InitializeComponent();
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;
radGridView1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
view.ColumnGroups[0].PinPosition = PinnedColumnPosition.Left;
}
Please see the attached screenshot.
Workaround: add the columns belonging to the pinned group in a reversed order.
Wrapping text in ColumnsGroupViewDefinition does not affect the size of the cells.
To reproduce:
- Create a grid with ColumnGroupsViewDefinition view( Column Groups View)
- Set the AutoSizeColumnsMode to fill
- Start the project and resize a column
- Resize a column then minimize and maximize
- The column have a different size
Workaround:
-Handle the form layout event like this:
void Form1_Layout(object sender, LayoutEventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.radGridView1.GridElement.SuspendLayout();
}
else
{
this.radGridView1.GridElement.ResumeLayout(true);
}
}
To reproduce: Create a RadGridView and set its view to ColumnGroupsViewDefinition following this article - http://www.telerik.com/help/winforms/gridview-viewdefinitions-column-groups-view.html. The text in the headers long enough so it does not fit in the cells. Using the ViewCellFormatting event set each cell's TextWrap property to true. You will notice that the header cells are not being TextWrapped
Currently, when you have an object which has more than one parent, the grid falls in an invalid state and shows the child under all of the parents, however, it does not behave correctly. As this is not supported scenario, the user should be notified via exception.
Workaround: use the CellValidating event
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.
To reproduce:
Add a RadGridView and use the RowFormatting event for showing rows with errors. Use a timer to change the data. The RowFormatting event fires when the user does not group rows. But after grouping the rows by any column, the grid is not refreshed according to the applied style in RowFormatting event. In order to reproduce the problem, use the following code:
private readonly BindingList<DataItem> _items = new BindingList<DataItem>();
private readonly Random _rnd = new Random();
public Form1()
{
InitializeComponent();
for (var i = 1; i <= 10; i++)
{
_items.Add(new DataItem("Text1 = " + i, "Type = None", _rnd.Next(0, 2) == 1));
}
radGridView1.DataSource = _items;
timer1.Start();
}
private void radGridView1_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e)
{
var item = e.RowElement.Data.DataBoundItem as DataItem;
if (item != null && item.IsDataCorrect)
{
e.RowElement.ResetValue(VisualElement.ForeColorProperty, ValueResetFlags.Local);
}
else
{
e.RowElement.ForeColor = Color.Red;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
foreach (var item in _items)
{
item.IsDataCorrect = _rnd.Next(0, 2) == 1;
}
}
ic class DataItem : INotifyPropertyChanged
private bool _isDataCorrect;
private string _text;
private string _type;
public DataItem(string text1, string type, bool isOk)
{
Text = text1;
Type = type;
IsDataCorrect = isOk;
}
public event PropertyChangedEventHandler PropertyChanged;
public bool IsDataCorrect
{
get
{
return _isDataCorrect;
}
set
{
if (_isDataCorrect != value)
{
_isDataCorrect = value;
OnPropertyChanged("IsDataCorrect");
}
}
}
public string Text
{
get
{
return _text;
}
set
{
if (_text != value)
{
_text = value;
OnPropertyChanged("Text1");
}
}
}
public string Type
{
get
{
return _type;
}
set
{
if (_type != value)
{
_type = value;
OnPropertyChanged("Type");
}
}
}
protected virtual void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
To reproduce:
private RadGridView radGridView1;
public Form1()
{
InitializeComponent();
radGridView1 = new RadGridView() { Dock = DockStyle.Fill };
Controls.Add(radGridView1);
List<Item> items = new List<Item>();
for (int i = 0; i < 10; i++)
{
items.Add(new Item(i, "Item" + i, DateTime.Now.AddDays(i)));
}
radGridView1.AutoGenerateColumns = true;
this.radGridView1.DataSource = items;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
this.radGridView1.CustomFiltering += radGridView1_CustomFiltering;
radGridView1.EnableCustomFiltering = true;
}
void radGridView1_CustomFiltering(object sender, GridViewCustomFilteringEventArgs e)
{
e.Handled = false;
e.Visible = true;
var item = (Item)e.Row.DataBoundItem;
if (item == null)
return;
if (item.Name.EndsWith("Item"))
{
e.Handled = true;
e.Visible = false;
}
}
public class Item
{
public int Id { get; set; }
public string Name { get; set; }
public Nullable<DateTime> Date { get; set; }
public Item(int id, string name, Nullable<DateTime> date)
{
this.Id = id;
this.Name = name;
this.Date = date;
}
}
Workaround:
private void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
this.radGridView1.MasterTemplate.Refresh();
}
To reproduce:
Add a RadGridView. Create a DataTable with 3 columns with data type - Decimal. To the last column set the following expression - "column1 + column2". Add some rows with some values. Turn on excel like filtering - http://www.telerik.com/help/winforms/gridview-filtering-excel-like-filtering.html. Subscribe to the CellValueChanged event and add the following code:
if (this.radGridView1.CurrentRow.DataBoundItem != null)
{
((DataRowView)this.radGridView1.CurrentRow.DataBoundItem).Row.EndEdit(); // force row subtotal update
}
Start the application and filter the last column by some of the available values. Change a value in one of the first two cells. You will notice that the last cell's value is not updated although it is updated in the data table. This behavior does not occur when the grid is not filtered.
To reproduce:
this.radGridView1.AllowEditRow = false;
this.radGridView1.AllowColumnHeaderContextMenu = true;
this.radGridView1.AllowCellContextMenu = true;
Workaround: subscribe to the ContextMenuOpening event and hide the items. An alternative solution is to use RadGridView in read-only mode.
To reproduce:
Add a RadGridView and three GridViewComboBoxColumns with repetitive values:
for (int i = 0; i < 3; i++)
{
List<int> datasource = new List<int>();
for (int j = 0; j < 12; j++)
{
datasource.Add(j);
}
this.Grid.Columns.Add(new GridViewComboBoxColumn()
{
DataSource = datasource
});
}
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 5; j++)
{
this.Grid.Rows.Add(i, i, i);
}
}
Start the project and sort second and last column by the same value and make sure that you have vertical scrollbar.
Select a cell in the second column change its value and press the tab key(or click on another cell in the same row). You will see that the scrollbar will go to the bottom of the grid.
Workaround:
Use the following class:
public class ActionExecuteHelper
{
#region Singleton
private static ActionExecuteHelper instance;
private static readonly object syncRoot = new object();
public static ActionExecuteHelper Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
{
instance = new ActionExecuteHelper();
}
}
}
return instance;
}
}
#endregion
private readonly Timer timer;
public ActionExecuteHelper()
{
this.timer = new Timer();
}
public void ExecuteDelayedAction(Action action, int delayInMilliseconds)
{
EventHandler timerTick = null;
timerTick = delegate
{
this.timer.Stop();
this.timer.Tick -= timerTick;
action.Invoke();
};
this.timer.Tick += timerTick;
this.timer.Interval = delayInMilliseconds;
this.timer.Start();
}
}
And use it with the following code
private int savedValue;
private void Grid_CellEndEdit(object sender, GridViewCellEventArgs e)
{
this.Grid.TableElement.VScrollBar.ValueChanged += ValueChangedDelegate;
}
private void ValueChangedDelegate(object sender, EventArgs e)
{
this.Grid.TableElement.VScrollBar.ValueChanged -= ValueChangedDelegate;
ActionExecuteHelper.Instance.ExecuteDelayedAction(new Action(this.SetScrollbarValue), 5);
}
private void SetScrollbarValue()
{
this.Grid.TableElement.VScrollBar.Value = savedValue;
}
private void Grid_ValueChanging(object sender, ValueChangingEventArgs e)
{
this.savedValue = this.Grid.TableElement.VScrollBar.Value;
}
This way the value of the scrollbar will be saved and restored.
To reproduce: - Add a column to the grid and try to set its IsPinned property to true.
To reproduce: 1. Add a RadGridView, set ShowRowHeaderColumn to false, AutoSizeColumnsMode to Fill and Dock to Fill. 2. Add 3 columns and 1 row. 3. Start the application and click the leftmost cell, you will notice that the header will move with one pixel to the right. 4. Click the rightmost cell and you will notice the header moving one pixel to the left
RadGridView - CustomGrouping event is not firing when you change some cell value and RadGridView is data bound via DataSource property.
Workaround:
1.Subscribe to CellEndEdit event of RadGridView:
this.radGridView1.CellEndEdit += new GridViewCellEventHandler(radGridView1_CellEndEdit);
2. Call Refresh method of MasterTemplate:
void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
this.radGridView1.MasterTemplate.Refresh();
}
If you change the RadGridView in design-time by property builder, the smart tag disappears after closing the builder.
To reproduce:
- Add GridViewDateTimeColumn.
- Set the editor properties:
private void radGridView_VehicleAbsenceTime_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
RadDateTimeEditor lEditor = radGridView_VehicleAbsenceTime.ActiveEditor as RadDateTimeEditor;
if (lEditor != null)
{
RadDateTimeEditorElement editorElement = (RadDateTimeEditorElement)lEditor.EditorElement;
editorElement.Format = DateTimePickerFormat.Custom;
editorElement.CustomFormat = "dd.MM.yyyy HH:mm";
editorElement.ShowUpDown = true;
}
}
- Start the application scroll to the bottom and start editing.
1. Use the following code snippet:
public Form1()
{
InitializeComponent();
this.radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.MasterTemplate.EnableAlternatingRowColor = true;
this.radGridView1.MasterTemplate.EnableFiltering = true;
this.radGridView1.MasterTemplate.MultiSelect = true;
for (int i = 0; i < 3; i++)
{
this.radGridView1.Columns.Add("Col"+i);
}
radGridView1.Rows.Add("test1", "test1", "test1");
radGridView1.Rows.Add("test2", "test2", "test2");
radGridView1.Rows.Add("test3", "test3", "test3");
radGridView1.Rows.Add("test4", "test4", "test4");
radGridView1.Rows.Add("test5", "test5", "test5");
}
2. Quickly click around the cells a few times, making sure to drag your mouse a bit to select a few rows on some of the clicks.
Then quickly click the filter. (sometimes it takes a few tries)
Workaround: use custom GridFilterRowBehavior
BaseGridBehavior gridBehavior = radGridView1.GridBehavior as BaseGridBehavior;
gridBehavior.UnregisterBehavior(typeof(GridViewFilteringRowInfo));
gridBehavior.RegisterBehavior(typeof(GridViewFilteringRowInfo), new CustomGridFilterRowBehavior());
public class CustomGridFilterRowBehavior : GridFilterRowBehavior
{
protected override bool ProcessMouseSelection(Point mousePosition, GridCellElement currentCell)
{
return false;
}
}
Self-referencing hierarchy does not work, when ColumGroupsViewDefinition is applied.
There is wrong current row selection for bound RadGridView, when using AddNew and ResetBindings methods on same BindingSource.