By default, in the Property Builder for GridView, the defaults are:
Header Text Alignment = Middle Center
Text Alignment = Middle Left.
This means that EVERY time I create a new grid, I have to remember to make them both the same.
Why make them different? It makes the grid look rubbish whenthe defaults are used.
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, "", " ");
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);
With releasing .NET 6, there are TimeOnly and DateOnly types which would be more appropriate for managing such values:
https://devblogs.microsoft.com/dotnet/date-time-and-time-zone-enhancements-in-net-6/
It would be good to add support for these types in GridViewDateTimeView.
Currently, the following code gives an exception when entering edit mode:
public RadForm1()
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add("DateOnly", typeof(DateOnly));
dt.Rows.Add(new DateOnly(2022,3,3));
this.radGridView1.AutoGenerateColumns = false;
GridViewDateTimeColumn dateColumn = new GridViewDateTimeColumn();
dateColumn.FieldName = "DateOnly";
this.radGridView1.Columns.Add(dateColumn);
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
}
Workaround: you can use the following custom TypeConverter:
public RadForm1()
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add("DateOnly", typeof(DateOnly));
dt.Rows.Add(new DateOnly(2022,3,3));
this.radGridView1.AutoGenerateColumns = false;
GridViewDateTimeColumn dateColumn = new GridViewDateTimeColumn();
dateColumn.DataType = typeof(DateTime);
dateColumn.FieldName = "DateOnly";
dateColumn.Format = DateTimePickerFormat.Custom;
dateColumn.CustomFormat = "dd/MM/yyyy";
dateColumn.FormatString = "{0:dd/MM/yyyy}";
dateColumn.DataTypeConverter = new DateOnlyConverter();
this.radGridView1.Columns.Add(dateColumn);
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
}
public class DateOnlyConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(DateTime);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is DateOnly && destinationType == typeof(DateTime))
{
DateOnly date = (DateOnly)value;
return new DateTime(date.Year, date.Month, date.Day);
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(DateTime) ;
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value is DateTime)
{
DateTime date = (DateTime)value;
return new DateOnly(date.Year, date.Month, date.Day);
}
return base.ConvertFrom(context, culture, value);
}
}
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.
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:
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
Currently, when you update the value of the checkbox cell (toggle/untoggle), Narrator reads the value only the first time after selecting the cell. Each next checking/unchecking does nothing.
It is expected from the Narrator to read the value of the RadCheckBoxEditor when it is being activated after entering edit mode. It the column uses EditMode.OnValueChange, the value changes also should be read by the Narrator.
Hello.
In my application, depending on the specific data in the grid I may want to warn a user who clicks on the header checkbox that changing all the values in that column may not be what he intends, allowing him to cancel out of the operation. I haven't found a handler that gets called when clicking on the header checkbox that allows me to cancel the event. How can I accomplish this?
Hi,
I have to transfer data from gridview to a .xlsm file which is for the salary transfer to the bank from the application (Template given by the Bank).
File screenshot attached.
Need to fill the cells from the loaded gridview to this template.
Please help; I have searched a lot but no luck.
Thank you very much.
Please refer to the following code snippet demonstrating how the comparer can be applied:
public RadForm1()
{
InitializeComponent();
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowHeaderCellButtons = true;
this.radGridView1.FilterPopupInitialized += radGridView1_FilterPopupInitialized;
}
private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
{
RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
if (popup != null)
{
popup.MenuTreeElement.TreeView.TreeViewElement.Comparer = new MyComparer(popup.MenuTreeElement.TreeView.TreeViewElement);
}
}
class MyComparer : TreeNodeComparer
{
public MyComparer(RadTreeViewElement treeView)
: base(treeView)
{
}
public override int Compare(RadTreeNode x, RadTreeNode y)
{
if (this.TreeViewElement.SortOrder == SortOrder.Descending)
{
return x.Text.CompareTo(y.Text);
}
return x.Text.CompareTo(y.Text) * -1;
}
}