Error on Dock = Fill the DataGrid. Dock = None works fine.

Hello, I made a Master Detail grid in a NET5 WinForms application, like this:

            sfDataGrid9.AutoGenerateColumns = false;
            sfDataGrid9.Columns.Add(new GridCheckBoxColumn() { MappingName = "Selected", HeaderText = "" });
            sfDataGrid9.Columns.Add(new GridTextColumn() { MappingName = "Codice", HeaderText = "Codice" });
            sfDataGrid9.Columns.Add(new GridTextColumn() { MappingName = "Nome", HeaderText = "Nome" });
            sfDataGrid9.Columns.Add(new GridDateTimeColumn() { MappingName = "DataInizio", HeaderText = "Data inizio", NullDisplayText = "" });
            sfDataGrid9.AddNewRowPosition = RowPosition.None;
            sfDataGrid9.AutoSizeColumnsMode = AutoSizeColumnsMode.Fill;

            GridViewDefinition specieDetailsView = new GridViewDefinition();
            specieDetailsView.RelationalColumn = "SpecieDetails";

            SfDataGrid specieGrid = new SfDataGrid();
            specieGrid.AutoGenerateColumns = false;
            specieGrid.AllowSorting = false;
            specieGrid.Columns.Add(new GridCheckBoxColumn() { MappingName = "Selected", HeaderText = "", AllowEditing = true });
            specieGrid.Columns.Add(new GridTextColumn() { MappingName = "TipoSpecieDesc", HeaderText = "Specie", AllowEditing = false });

            specieDetailsView.DataGrid = specieGrid;
            sfDataGrid9.DetailsViewDefinitions.Add(specieDetailsView);


and it works fine, if the DataGrid is not docked

If I just set its Dock property to Fill (is inside a panel), I receive the following error in Application.Run(new MainForm())
Once I revert the Dock to none, it works fine.


System.ArgumentOutOfRangeException: '4 out of range 0 to 3 Arg_ParamName_Name'
4 out of range 0 to 3 (Parameter 'to')

   at Syncfusion.WinForms.GridCommon.ScrollAxis.DistanceRangeCounterCollection.CheckRange(String paramName, Int32 from, Int32 to, Int32 actualValue)
   at Syncfusion.WinForms.GridCommon.ScrollAxis.DistanceRangeCounterCollection.SetRange(Int32 from, Int32 to, Double distance)
   at Syncfusion.WinForms.GridCommon.ScrollAxis.LineSizeCollection.InitializeDistances()
   at Syncfusion.WinForms.GridCommon.ScrollAxis.LineSizeCollection.ResumeUpdates()
   at Syncfusion.WinForms.DataGrid.AutoSizeController.Refresh()
   at Syncfusion.WinForms.DataGrid.TableControl.OnSizeChanged(EventArgs e)
   at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
   at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height)
   at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
   at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.SetBounds(Rectangle bounds, BoundsSpecified specified)
   at System.Windows.Forms.Layout.DefaultLayout.TryCalculatePreferredSizeDockedControl(IArrangedElement element, Rectangle newElementBounds, Boolean measureOnly, Size& preferredSize, Rectangle& remainingBounds)
   at System.Windows.Forms.Layout.DefaultLayout.LayoutDockedControls(IArrangedElement container, Boolean measureOnly)
   at System.Windows.Forms.Layout.DefaultLayout.TryCalculatePreferredSize(IArrangedElement container, Boolean measureOnly, Size& preferredSize)
   at System.Windows.Forms.Layout.DefaultLayout.LayoutCore(IArrangedElement container, LayoutEventArgs args)
   at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container, LayoutEventArgs layoutEventArgs)
   at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent)
   at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args)
   at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty)
   at System.Windows.Forms.Control.OnResize(EventArgs e)
   at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
   at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
   at System.Windows.Forms.Control.UpdateBounds()
   at System.Windows.Forms.Control.WmWindowPosChanged(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at Syncfusion.WinForms.DataGrid.SfDataGrid.WndProc(Message& m)
   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, WM msg, IntPtr wparam, IntPtr lparam)

Is there anything else I can do to Dock the grid to fill the Panel?

Thanks




1 Reply 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team March 1, 2021 12:07 PM UTC

Hi Mattia, 

Thanks for contacting Syncfusion support.  

We checked the reported problem when docking the SfDataGrid in our end. But the DataGrid loaded properly and we are unable to reproduce the exception. The sample we have used to check the reported issue is available in the following link for your reference.  


Please have a look at this sample and revert to us with details if the reported issue occurs in this sample. If reproduced, kindly revert to us with the Syncfusion product version you are using in your end. Otherwise please check the sample and let us know if we have included all the customization you have done in your sample or we missed any. Or try to reproduce the reported in this sample and revert to us with modified sample. It will be more helpful for us to find the exact cause for the issue and to provide a prompt solution.   

Regards, 
Mohanram A. 


Marked as answer
Loader.
Up arrow icon