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);
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;
}
}
To reproduce: please run the attached sample project and follow the steps illustrated in the attached gif file: Scrolling to a newly added row does not work when inner templates are visible. Add data to the inner templates of several rows near the bottom using the button. Expand these inner templates so they are all visible. Scroll back up to the top. Add a new item to the outer grid normally. The table will jump to where it things the new item is but will fall short, instead scrolling to a location in one of the inner templates. Workaround: private void RadGridView1_UserAddedRow(object sender, GridViewRowEventArgs e) { foreach (GridViewRowInfo row in this.radGridView1.Rows) { if (row.IsExpanded) { row.IsExpanded = false; row.IsExpanded = true; } } }
Use the following code snippet:
GridViewDateTimeColumn orderDate = this.radGridView1.Columns["OrderDate"] as GridViewDateTimeColumn;
orderDate.Format = DateTimePickerFormat.Custom;
orderDate.CustomFormat = "dd-MM-yyyy";
orderDate.FormatString = "{0:dd-MM-yyyy}";
GridViewDateTimeColumn shippedDate = this.radGridView1.Columns["ShippedDate"] as GridViewDateTimeColumn;
shippedDate.Format = DateTimePickerFormat.Custom;
shippedDate.CustomFormat = "dd-MM-yyyy";
shippedDate.FormatString = "{0:dd-MM-yyyy}";
When the grid is grouped by a column with a specific format, it should be taken in consideration by the group row as well.
Use the following code snippet:
public RadForm1()
{
InitializeComponent();
GridViewDecimalColumn idColumn = new GridViewDecimalColumn("Id");
this.radGridView1.Columns.Add(idColumn);
GridViewTextBoxColumn nameColumn = new GridViewTextBoxColumn("Name");
this.radGridView1.Columns.Add(nameColumn);
GridViewDateTimeColumn dateColumn = new GridViewDateTimeColumn("Date");
dateColumn.FilteringMode = GridViewTimeFilteringMode.Date;
dateColumn.Format = DateTimePickerFormat.Custom;
dateColumn.CustomFormat = "dd/MM/yyyy";
dateColumn.FormatString = "{0:dd/MM/yyyy}";
this.radGridView1.Columns.Add(dateColumn);
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
for (int i = 0; i < 50; i++)
{
this.radGridView1.Rows.Add(i,"Row"+i,DateTime.Now.AddDays(i));
}
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowHeaderCellButtons = true;
this.radGridView1.ShowFilteringRow = false;
this.radGridView1.FilterExpressionChanged += RadGridView1_FilterExpressionChanged;
}
private void RadGridView1_FilterExpressionChanged(object sender, FilterExpressionChangedEventArgs e)
{
Console.WriteLine(e.FilterExpression);
}
If I use the calendar control then the sequence works:
Click the filter button
Click Available filters
Click Equals
Click the calendar button in the value field
Click on December 10, 2021
But if I do not use the calendar control then it does not work. This sequence produces no results:
Click the filter button
Click Available filters
Click Equals
Click on the day component of the value field
Type in 10
Click OK
Workaround:
private void RadGridView1_CreateCompositeFilterDialog(object sender, GridViewCreateCompositeFilterDialogEventArgs e)
{
e.Dialog = new CustomCompositeDataFilterForm();
}
public class CustomCompositeDataFilterForm : CompositeDataFilterForm
{
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
if (GridFilterCellElement.ValidateUserFilter(this.FilterDescriptor))
{
CompositeFilterDescriptor cfd = this.FilterDescriptor as CompositeFilterDescriptor;
if (cfd != null)
{
foreach (FilterDescriptor fd in cfd.FilterDescriptors)
{
TrimTimePart(fd);
}
}
else
{
TrimTimePart(this.FilterDescriptor);
}
}
}
private void TrimTimePart(FilterDescriptor filterDescriptor)
{
CompositeFilterDescriptor cfd = filterDescriptor as CompositeFilterDescriptor;
if (cfd != null)
{
foreach (FilterDescriptor fd in cfd.FilterDescriptors)
{
TrimTimePart(fd);
}
}
else
{
DateTime dateValue = DateTime.MinValue;
if (DateTime.TryParse(filterDescriptor.Value + "", out dateValue))
{
dateValue = dateValue.Date;
filterDescriptor.Value = dateValue;
}
}
}
}
There are situations where SelectedRows won't return the number of rows preselected when using Begin/EndUpdate even though it seems like there's a row selected in the UI. By preselected I mean the row that looks selected after the rows has been added. This bug has caused some problems for us because the user tried some action on a row they thought was preselected and it would fail.
One situation I found where this bug can be reproducted is by using SortOrder in combination of Begin/EndUpdate. There are probably more situations but I hope this one will let you find the underlying bug.
The attached project contains a simple form with a RadGridView which will contain a list of persons. The list is populated by this method:
public void PopulateGridView(List<Person> persons)
{
PersonGridView.BeginUpdate();
PersonGridView.DataSource = persons;
PersonGridView.EndUpdate();
PersonGridView.Columns[nameof(Person.LastName)].SortOrder = RadSortOrder.Ascending;
}
There are two buttons: "Step one" and "Step two". The first will mimick a situation where the user search a database for persons and none will be found. By clicking the "Get selected rows" you will see that the SelectedRows will return zero rows which is correct.
But when you afterwards click "Step two" (which will add five rows) it seems like there's one row preselected. I would expect the SelectedRows to return that row but by clicking "Get selected rows" again you will see that the returned rows are zero still. The CurrentRow, however is set to the preselected row as expected.
If you start by clicking "Step two" the SelectedRows actually returns the correct rows. Quite strange :-)
I know this is a very small issue and can be avoided. But as I mentioned there are other situations where this problem occurs and it's quite hard to figure out exactly what causes it.
Thank you for your help.
Best regards
Ulrik Skovenborg
Please run the attached sample project. The row's height in the print document is not adjusted according to the column's width in the print page.
Workaround:
Usually for such cases it is convenient to increase the column's width in order to reduce its height and thus it would be able to fit the print page's height. In addition to adjusting the column's width, feel free to use multi-page printing:
Dear Support team,
Our Application issue: While running application in assistive mode and having a grid with large number of columns, Narrator/JAWS starts reading each Column Value as "DbNull"
while User is Tabbing through selected Row. (Please see attach Video for better understanding.)
I also created a sample Program:
1. Build Win Form app having a RadGridView. [Sample Attached in 1514161]
2. Start Win 10 Narrator App
3. Run App from Step #1 [Note: Please do not Resize Main Form yet]
4. Start Tabbing from Grid selected Row. Narrator does not read/speak Cell Values.
5. Now Close & Run Application again and Maximize Window. Repeat Step #4. Narrator reads/speak Cell Values as expected.
It seems reads all values fine until they are visible, and once you continue tabbing and horizontal scrolling happens and then stops reading.
Please advice. A Fix for it would be a great help!
Looking forward to hear back!
Thanks and Regards,
Vivek
Sr. .Net Developer
The main purpose is optimizing memory consumption and performance when generating large pdf documents.
Resource: https://www.telerik.com/blogs/pdf-stream-processing-reliable-and-efficient-processing-of-pdf-files
I want that the user can select a value from al list like in excel:
Currently, when using the Excel-like filtering and RadListFilterPopup it does not allow filtering by time, only by date:
To reproduce: - Add ColumnGroupsViewDefinition and set ShowHeader to false. - Set AutoSizeRows to true. Workaround: Manually set the row height. ViewDefinition.ColumnGroups(0).Rows(0).MinHeight = 50
When you have a checkbox column in the grid and group by a certain column, you should have the possibility to check-all rows inside a group without the necessity of expanding the group and checking each separate row.
The group row should have a checkbox as well. When you toggle it, all data rows or nested groups should also be toggled. The parent group should also be adjusted correctly.
Workaround: The following knowledge base article demonstrates a sample approach how to extend the default group row and add a checkbox. However, it would be necessary to modify and extend it in a way to cover the cases with nested groups:
https://www.telerik.com/support/kb/winforms/details/check-all-functionality-in-group-rows
Please refer to the attached sample project.
If the main Cars list is not empty, the child templates have correct captions:
However, if initially there are no Cars and you add a new one via the new row, the captions of the child template remains with the default value ("table"):