Current filter:
                                You should refresh the page.
                                  • Hi guys,

                                    I have a small issue with a grid I am displaying. Basically I have the visibility set to collapsed in XAML.

                                    Then a button is clicked after initial load etc. I then set the grid to visible.

                                    However I cannot get it to bestfit the columns when this happened even if I call the method after it has been set to visible, am I missing something?

                                    Many thanks,
                                    Joe

                                1 Solution

                                Creation Date Importance Sort by

                                Hello Joe,

                                Most likely this issue occurs because the grid is not completely loaded yet when the BestFitColumns is called after setting the GridControl's Visibility property to Visible. From this point, please try calling the BestFitColumns method using Dispatcher as follows:

                                [C#]
                                grid.Visibility = Visibility.Visible; Dispatcher.BeginInvoke(new Action(() => { view.BestFitColumns(); }), DispatcherPriority.Normal);

                                I look forward to your results.

                                Thanks,
                                Michael

                                • Joseph Sargeant 09.18.2019

                                  Hi MIchael,

                                  No I am afraid this didn't work I have edit the sample you sent on the other ticket. Please see attached.

                                  If you change the visibility in XAML to hidden and then click the button that has the desired effect but when it's collapsed it does not.

                                  Many thanks,
                                  Joe

                                • Michael Ch (DevExpress Support) 09.18.2019

                                  Thank you for the modified sample project, Joe. In your scenario, calling the BestFitColumns method has no effect for the following reasons:

                                  • The view's AutoWidth is set to true. In this case, the GridControl changes the column widths so that the total columns' width matches the grid's width.
                                  • The BestFitColumns method is called immediately after setting the grid's Visibility property without a delay as I described in my answer.

                                  After corresponding changes - setting the AutoWidth property to false and calling the BestFitColumns method using Dispatcher, your sample works as expected on my side - all columns are resized depending on their content:

                                  T815685.gif

                                  Attached is the updated sample project.

                                  Thanks,
                                  Michael

                                • Joseph Sargeant 09.18.2019

                                  Thanks Michael that fixed I actually sent you the wrong sample without the dispatcher but I changed it to false and changed the dispatcher priority to loaded and it worked :-).

                                  Thanks Michael much appreciated :-).

                                  Joe

                                • Michael Ch (DevExpress Support) 09.18.2019

                                  You're welcome!