When the GridViewComboBoxColumn is added for the master level, once the FieldName property is set, the DataType is synced with its type:
However, for the child levels, this logic is not executed automatically.
Steps to reproduce:
1. Add a RadGridView with AutoGenerateHierarchy set to true.
2. Set the DataSource to Northwind DataSet and DataMember to Categories:
3. Open the grid's Property Builder and add a combo column for the child level:
4. Set the column's DataSource property.
Expected behavior: DataSource collection is properly set:
Actual behavior: blank property grid with settings for the column:
When paging is enabled in RadGridView and a row is pinned, it is visible among all pages. However, it is possible to paste in it only from the page to which it originally belongs.
Use the following setup:
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, "Row" + i);
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.EnableWithNotifications;
this.radGridView1.EnablePaging = true;
1. Copy the entire content of a random row
2. Navigate to another page and pin a row
3. Change the page and try to paste the clipboard content to the pinned row
Expected behavior: the content is successfully pasted no matter of the current page
Actual behavior: the content is pasted only if the use navigates to the page to which the pinned row originally belongs
Use the following setup:
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
for (int i = 0; i <5; i++)
{
dt.Rows.Add(i, "Row"+i);
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.Enable;
1. Copy the entire content of a random row.
2. Pin another row to the top
3. Paste the clipboard data to the pinned row
Expected result: the content is successfully pasted in the pinned row.
Observed result: the pinned row disappears.
When you use var, object is assumed. Of course, the object contains a GridViewCellInfo, but you have to cast it first to use one of its members.
The goal is to prevent unnecessary casts.
In this case, we have GridViewTextBoxColumn and GridViewComboBoxColumn after it. We want to trigger the edit on the second column at the moment it is navigated with the key arrow navigation. To do that BeginEdit() method is called. However, manually calling this method will trigger key events on the editor inside the GridViewComboBoxColumn which will bubble to the parent and move the current cell to the next column (skipped the GridViewComboBoxColumn )
This behavior could be workaround by delaying the execution of the BeginEdit() method.
public class CustomGridBehavior : BaseGridBehavior
{
Timer timer = new Timer();
public override bool ProcessKey(KeyEventArgs keys)
{
var result = base.ProcessKey(keys);
if((keys.KeyCode == Keys.Left || keys.KeyCode == Keys.Right) && this.GridControl.CurrentColumn is GridViewComboBoxColumn)
{
timer.Interval = 100;
timer.Tick += Timer_Tick;
timer.Start();
}
return true;
}
private void Timer_Tick(object sender, EventArgs e)
{
timer.Stop();
this.GridControl.BeginEdit();
}
}
this.radGridView1.GridBehavior = new CustomGridBehavior();
To reproduce:
1.Open the Demo application >> VirtualGrid >> First Look example and resize a column.
2.Then, move the form to a monitor with higher than 100% DPI scale factor.
Expected: the columns' width settings should be preserved.
Actual: the columns' width settings got reset.
In this particular scenario, the RadDropDownListEditor element inside the RadComboBoxColumn cell contains an empty string item. So when we try to clear the value of the cell and leave it empty, the internal logic will return the last selected valid value. The following code demonstrate a simple example:
DataTable dt = new DataTable();
dt.Columns.Add("id", typeof(int));
dt.Columns.Add("codice", typeof(string));
dt.Columns.Add("nome", typeof(string));
dt.Rows.Add(0, "", "");
dt.Rows.Add(1, "I622", "Seravezza");
dt.Rows.Add(2, "G628", "Pietrasanta");
dt.Rows.Add(3, "L833", "Viareggio");
The first row in the DataTable which the RadGridView contains an empty value. If for example, the second row is selected and we use Backspace/Delete to clear the text and move to another cell. The selected item won't be changed. The cell value won't be cleared. To workaround this we could avoid using empty strings. We could use space or some other symbol to allow the user to clear the value from the drop-down popup.
dt.Rows.Add(0, "", "-");
OR
dt.Rows.Add(0, "", " ");
In this case, the GridViewCheckBoxColumn is nullable bool? property and the ThreeState property is set to true. When we try to use the filter context menu to filter the cell by null values, the filter is not applied.
Steps to reproduce:
1. Please run the attached sample project
2. Filter grid so only one row is left
3.Copy the first cell with the content menu. The following error occurs:
************** Exception Text ************** System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Telerik.WinControls.UI.MasterGridViewTemplate.CopySelected(GridViewCellInfo[] cells, String format, Boolean cut, Boolean cutOperation, StringBuilder content) in C:\Work\Development\RadControls\RadGridView\Code\Data\MasterGridViewTemplate.cs:line 1491 at Telerik.WinControls.UI.MasterGridViewTemplate.ProcessContent(String format, Boolean cut, Boolean cutOperation) in C:\Work\Development\RadControls\RadGridView\Code\Data\MasterGridViewTemplate.cs:line 1291 at Telerik.WinControls.UI.MasterGridViewTemplate.CopyContent(Boolean cut) in C:\Work\Development\RadControls\RadGridView\Code\Data\MasterGridViewTemplate.cs:line 1256 at Telerik.WinControls.UI.MasterGridViewTemplate.Copy() in C:\Work\Development\RadControls\RadGridView\Code\Data\MasterGridViewTemplate.cs:line 2066 at Telerik.WinControls.UI.GridDataCellElement.ItemCopy_Click(Object sender, EventArgs e) in C:\Work\Development\RadControls\RadGridView\Code\UI\GridViews\TableView\Cells\GridDataCellElement.cs:line 380 at Telerik.WinControls.RadElement.OnClick(EventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 5096 at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e) in C:\Work\Development\RadControls\RadControlsUI\UIElements\Buttons\RadButtonItem.cs:line 566 at Telerik.WinControls.UI.RadMenuItem.OnClick(EventArgs e) in C:\Work\Development\RadControls\RadControlsUI\Menu\RadMenuItem.cs:line 685 at Telerik.WinControls.RadElement.DoClick(EventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 5160 at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 4274 at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadItem.cs:line 779 at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 4181 at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 5273 at Telerik.WinControls.RadElement.CallDoMouseUp(MouseEventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Element\RadElement.cs:line 5495 at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Control\ComponentInputBehavior.cs:line 75 at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e) in C:\Work\Development\RadControls\RadControl\TPF\Control\RadControl.cs:line 1206 at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at Telerik.WinControls.RadControl.WndProc(Message& m) in C:\Work\Development\RadControls\RadControl\TPF\Control\RadControl.cs:line 1550 at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m) in C:\Work\Development\RadControls\RadControlsUI\GenericPopup\RadPopupControlBase.cs:line 795 at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
GridViewCellInfo offers Style property which allows you to customize the style for the cells defined at the data cell's level: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formating-examples/style-property
This functionality should work for the header cells as well like this:
GridViewCellInfo cell = this.radGridView1.MasterView.TableHeaderRow.Cells[0];
cell.Style.CustomizeFill = true;
cell.Style.GradientStyle = GradientStyles.Solid;
cell.Style.BackColor = System.Drawing.Color.FromArgb(162, 215, 255);
Run the attached sample project on a monitor with 100% DPI scaling. Then, try moving the form to the second monitor with 150% DPI scaling. You will notice that the following error occurs:
Workaround: instead of using a RadTextBoxControlElement in the custom cell, feel free to use a RadTextBoxElement. However, please have in mind that RadTextBoxElement hosts the MS TextBox and using controls in grid cells may slow down the scrolling and will cause visual glitches as they do not support clipping.
ArgumentOutOfRangeException is thrown when the control is auto-sized (AutoSize = true) and we try to select all (MultiSelect = true with CellSelect) rows by clicking and moving the mouse.
As a workaround, we could set the MaximumSize property of the RadGridView.
this.radGridView1.MaximumSize = new Size(1000,1000);
Use the following code snippet:
public RadForm1()
{
InitializeComponent();
this.radGridView1.Columns.Add("TextColumn");
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
for (int i = 0; i < 30; i++)
{
this.radGridView1.Rows.Add(Guid.NewGuid().ToString());
}
this.radGridView1.CellValidating += radGridView1_CellValidating;
this.radGridView1.EditorManager.CloseEditorWhenValidationFails = false;
}
private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e)
{
if (e.Value == null || e.Value == "")
{
e.Cancel = true;
RadMessageBox.Show("Value can't be empty!");
}
}
Steps:
1. Clear the value of a cell
2. While the editor is active with an empty value, click the vertical scrollbar to trigger scrolling.
Actual: the scrolling is performed and the editor is closed with the previous value no matter when the validation fails and the CloseEditorWhenValidationFails property is set to false.
Expected: the scrolling should be blocked if the validation fails. We should offer the same behavior when scrolling with the mouse wheel, clicking another cell or clicking the vertical scrollbar (or any of its elements).
Workaround:
public class MyGrid : RadGridView
{
public override string ThemeClassName
{
get
{
return typeof(RadGridView).FullName;
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
RadScrollBarElement scrollBarAtPoint = GetScrollbarElementAtPoint<RadScrollBarElement>(this.GridViewElement.ElementTree, e.Location) as RadScrollBarElement;
GridViewEditManager editManager = this.EditorManager;
if (scrollBarAtPoint != null && this.ActiveEditor != null && !editManager.CloseEditorWhenValidationFails)
{
bool isClosed = editManager.CloseEditor();
if (!isClosed)
{
return;
}
}
base.OnMouseDown(e);
}
internal T GetScrollbarElementAtPoint<T>(RadElementTree componentTree, Point point) where T : RadElement
{
if (componentTree != null)
{
RadElement elementUnderMouse = componentTree.GetElementAtPoint(point);
while (elementUnderMouse != null)
{
T item = elementUnderMouse as T;
if (item != null)
{
return item;
}
elementUnderMouse = elementUnderMouse.Parent;
}
}
return null;
}
}