Completed
Last Updated: 21 Sep 2022 12:57 by ADMIN
Release R3 2022 SP1
Please run the attached sample project and click one of the column headers. You will notice that the column is not sorted.
Declined
Last Updated: 16 Feb 2024 22:24 by ADMIN

C#. net core 6, winforms application, TekerikNuGet3 package source, UI.for.WinForms.AllControls.NetCore package 2022.2.622

I am trying to export selected cells from a RadGridView as a csv file.

When using "var exporter = new ExportToCSV(Dgv)" then "exporter.RunExport(fileName);" writes the csv file correctly. It exports every cell.

It doesn't support exporting selections so I wrote a function to do this . The one below is what I used in my project to test what I was doing. It initially writes the csv to a worksheet and wrote that using formatprovider to file, then I just created a stringbuilder adding quotes and appended that to the file afterwards.

Writing the worksheet, the csv values haven't been quoted, plus number fields have had leading zeros removed which proves to be a problem when telephone numbers are stored in a field.

So I googled and found the Settings property which is there to set csv options. But they are private, not public therefore I can't set up the csv propertly.

private void radButton1_Click(object sender, EventArgs e)
  {

    var workbook = new Workbook();
    var worksheet = workbook.Worksheets.Add();

    var rowIndex = 0;
    var columnIndex = -1;
    var sb = new StringBuilder();
    var prevColumnIndex = -1;

    // ForEach cell are accessed vertically then horizontally.
    foreach (var cell in Dgv.SelectedCells)
    {
      // Cell is included in selection even if it's invisible
      // so check visibility and ignore if it isnt
      if (!cell.ColumnInfo.IsVisible) continue;

      // At bottom of column, rownum will change. Watch for this
      // and reset x and y values
      var rowNum = cell.RowInfo.Index;
      if (rowNum != prevColumnIndex)
      {
        prevColumnIndex = rowNum;
        rowIndex = 0;
        columnIndex++;
        sb.AppendLine("");
      }
      else if (!string.IsNullOrEmpty(sb.ToString()))
        sb.Append(",");

      var value = cell.Value;
      worksheet.Cells[columnIndex, rowIndex++ ].SetValue(value.ToString());
      sb.Append($"\"{value.ToString()}\"");
    }

    var fileName = @"C:\temp\SampleFile.csv";

    IWorkbookFormatProvider formatProvider = new CsvFormatProvider();
    using var output = new FileStream(fileName, FileMode.Create);
    formatProvider.Export(workbook, output);
    output.Close();

    // Write contents of sb to the file for comparison sake
    File.AppendAllText(fileName, sb.ToString());

  }

Completed
Last Updated: 13 Nov 2024 12:45 by ADMIN
Release 2024.4.1113 (2024 Q4)

Run the attached project on a monitor with 100% DPI scaling and open the Excel-like filter popup:

100%:

After moving the form to the second monitor with 150% DPI scaling, the filter popup is not OK:

150%:

The popup is smaller and smaller with each next opening (see the attached gif file) at 150%. If you decide to move back the form on the monitor with 100% DPI scaling, the filter popup is not scaled properly.

Completed
Last Updated: 23 Sep 2022 13:07 by ADMIN
Release R3 2022

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);

Completed
Last Updated: 23 Sep 2022 13:07 by ADMIN
Release R3 2022

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.

Completed
Last Updated: 23 Sep 2022 13:07 by ADMIN
Release R3 2022
When the MultiSelect property is false and the SelectionMode is set to CellSelect, clicking on the row header, all cells in the row will be selected. In this case, only the current cell in the same column needs to be changed. 
Completed
Last Updated: 23 Sep 2022 13:07 by ADMIN
Release R3 2022
The event handlers of these events are not correctly implemented. A NullReferenceException could raise if a task executed on a different thread unsubscribes from the event.
Completed
Last Updated: 31 Jan 2024 11:39 by ADMIN
Release 2024 Q1 (2024.1.130)

When the columns are auto-generated, the way to modify the columns is to use the Columns collection. We could expose an event that will be called when the columns are auto-generating. From the event arguments, we could get the newly created column and replace with if needed or modify it. Similar to the CreateRow event of the control.

Completed
Last Updated: 11 Oct 2022 08:07 by ADMIN
Release R3 2022
Class GridViewRowCollection implements IList<T>.

Class GridViewCellInfoCollection does not implement any generic interfaces.
Unplanned
Last Updated: 08 Jun 2022 07:52 by Suresh

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;
            }
        }

 

 

Completed
Last Updated: 06 Jun 2022 09:32 by ADMIN
Release R2 2022 (LIB 2022.2.606)

Steps to reproduce:

1. Run the sample project and select a row inside the grid

2. Press Ctrl+B

The following error occur:

Workaround: set the EnableFastScrolling property to false.

Completed
Last Updated: 20 May 2022 13:35 by ADMIN
Release R2 2022 SP1

Run the attached project and click List then Export.

Expected:

Actual:

Workaround:

    Private Sub RadButton2_Click(sender As Object, e As EventArgs) Handles RadButton2.Click
        Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(gvAssetSchedule)
        AddHandler spreadExporter.CellFormatting, AddressOf spreadExporter_CellFormatting
        Dim exportRenderer As New SpreadExportRenderer()
        spreadExporter.ExportVisualSettings = True
        Dim filename = "..\..\export" & DateTime.Now.ToLongTimeString().Replace(":", "_") & ".xlsx"
        spreadExporter.RunExport(filename, exportRenderer)
        Process.Start(filename)
    End Sub

    Private Sub spreadExporter_CellFormatting(sender As Object, e As Telerik.WinControls.Export.CellFormattingEventArgs)
        If e.GridCellInfo Is Nothing Then
            Dim selection As CellSelection = e.CellSelection
            Dim range As CellRange = selection.CellRanges(0)
            Dim val = selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).GetValue()
            Dim format As New CellValueFormat("@")
            selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).SetFormat(format)
            Dim dt As New DateTime(1900, 1, 1)
            Dim parsedDays = 0
            If Integer.TryParse(val.Value.RawValue, parsedDays) Then
                dt = dt.AddDays(parsedDays)
                selection.Worksheet.Cells(range.FromIndex.RowIndex, range.FromIndex.ColumnIndex).SetValue(dt.Year & "-" & MonthName(dt.Month))
            End If
        End If
    End Sub

Completed
Last Updated: 06 Jun 2022 09:31 by ADMIN
Release R2 2022 (LIB 2022.2.606)

Use the following code: 

        public RadForm1()
        {
            InitializeComponent();

            DataTable dt = new DataTable();
            dt.Columns.Add("Id");
            dt.Columns.Add("Name");
            for (int i = 0; i < 10; i++)
            {
                dt.Rows.Add(i, "Item" + i); 
            }
            this.radGridView1.DataSource = dt; 
            this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; 
             
            this.radGridView1.CellValidating += radGridView1_CellValidating;
        }

        private void radGridView1_CellValidating(object sender, CellValidatingEventArgs e)
        {
            if (e.Column.Index == 0 && e.ActiveEditor != null && e.Value + "" == "1")
            { 
                e.Cancel = true;
                RadMessageBox.Show("IncorrectValue");
            }
        }

Follow the steps:

1. Scroll to the last row.

2. Enter value "1" in the first cell of the last row

3. Click the area above the scrollbar's thumb to trigger scrolling to the top. You will notice that the message box will be shown and the view will be scrolled. Once the message is closed, the error occurs.

Workaround: 

        public class CustomGridView : RadGridView
        {
            public override string ThemeClassName  
            { 
                get 
                { 
                    return typeof(RadGridView).FullName;  
                }
            }

            protected override void OnMouseDown(MouseEventArgs e)
            {
             RadScrollBarElement scrollbar=   this.GridViewElement.ElementTree.GetElementAtPoint ( e.Location) as RadScrollBarElement;
             if (scrollbar!=null && this.IsInEditMode)
             {
                    this.EditorManager.CloseEditorWhenValidationFails = false;
                    this.EditorManager.CloseEditor();
                    return;
             }
                base.OnMouseDown(e);
            }
        }

 

 

Completed
Last Updated: 26 Apr 2022 08:39 by ADMIN
Release R2 2022

Please refer to the below gif file. You will notice that the drop row line is shown only when dropping in the same grip but not when dropping on another grid:

Workaround: use the project in the following forum post: https://www.telerik.com/forums/preview-drop---drag-drop-between-gridview#5477699 

Completed
Last Updated: 13 Apr 2022 11:08 by ADMIN
Release R2 2022

ComboBox column DataSource property is not visible in the Designer MS Property Builder when the previously selected node was RadGridView. 

Declined
Last Updated: 25 Mar 2022 11:39 by Ian
Created by: Ian
Comments: 6
Category: GridView
Type: Feature Request
0

Eery time I use the GridView, I have to remember to un-select the last item in the list.

This is almost always to wrong thing to be selected - so why select it by default?

..and the way to swith this 'feaure' off isn't obvious - I always have to look it up....RadGridView1.CurrentRow = Nothing

Completed
Last Updated: 14 Apr 2022 08:26 by ADMIN
Release R2 2022

Steps to reproduce:

1.Run the attached sample project.

2.Group by the ProductID column

3.Select Page 4

4. Expand the top group row. You will notice that the grid jumps to a previous row.

Expected:

Actual:

Workaround:

 

        public class CustomGrid : RadGridView
        {
            public override string ThemeClassName
            {
                get
                {
                    return typeof(RadGridView).FullName;
                }
            }
            protected override void OnMouseDown(MouseEventArgs e)
            {
                GridExpanderItem expander = this.ElementTree.GetElementAtPoint(e.Location) as GridExpanderItem;
                if (expander != null)
                {
                    flag = true;
                }
                base.OnMouseDown(e);
            }

            protected override void OnMouseUp(MouseEventArgs e)
            {
                base.OnMouseUp(e);
                flag = false;
            }

            bool flag = false;

            protected override void OnPageChanging(object sender, PageChangingEventArgs e)
            {
                if (flag)
                {
                    e.Cancel = true;
                }
                base.OnPageChanging(sender, e);

            }
        }

 

Completed
Last Updated: 22 Mar 2022 13:50 by ADMIN
Release R2 2022 (LIB 2022.1.322)

When the RadGridView AutoSize property is set to true and a row is expanded, an exception is thrown:

System.InvalidOperationException: 'MeasureOverride returned positive infinity: Telerik.WinControls.UI.GridDetailViewRowElement'

 

A possible workaround is to replace the GridDetailViewRowElement with your own class. Then overriding the MeasureOverride method we can pass valid size to the element.

private void RadGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e)
{
    if (e.RowInfo is GridViewDetailsRowInfo)
    {
        e.RowElement = new MyGridDetailViewRowElement();
    }
}

public class MyGridDetailViewRowElement : GridDetailViewRowElement
{
    protected override SizeF MeasureOverride(SizeF availableSize)
    {
        var baseSize =  base.MeasureOverride(availableSize);
        if(baseSize.Width == float.PositiveInfinity)
        {
            baseSize.Width = 800;
        }
        return baseSize;
    }
}

Unplanned
Last Updated: 03 Mar 2022 08:49 by Alessandro
Created by: Alessandro
Comments: 0
Category: GridView
Type: Feature Request
1

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);
            }
        }

 

    
Declined
Last Updated: 16 Feb 2022 05:23 by ADMIN
Created by: alex
Comments: 3
Category: GridView
Type: Feature Request
0

Hi. it was great to see the option "ImageOnly", for columns of small width, where only the image is placed in the header, and the "HederText" property was set, for the correct display of the grouping field

GridViewDataColumn column;

column.HeaderText = "Счет";

column.HeaderImage = ...; // some img

column.TextImageRelation = TextImageRelation.Overlay;



GridViewDataColumn column;

column.HeaderText = "";

column.HeaderImage = ...; // some img

column.TextImageRelation = TextImageRelation.Overlay;

it’s impossible to choose one thing, either an ugly header, or a grouping without a description