Hi,
In my application, the number of columns are not predefined it could only be a single column or even more the 20 columns at a timeand I don't want any black spaces in my grid
However, I cannot set the property of DisplayLayout.AutoFitStyle to ResizeAllColumn because if the column count is greater 10 it would try to fit all the column in the given space hence disrupting the UI Neither could I set the property to None as if there is lesser then 5 column there will be blank space left in the UI
I tried the following code snippet (which I found somewhere from Infragistic's forms)
DisplayLayout.AutoFitStyle = HasScrollBar() ? AutoFitStyle.None : AutoFitStyle.ResizeAllColumns;
public bool HasScrollBar() { this.Update(); var dataAreaUIElement = DisplayLayout.UIElement.GetDescendant(typeof(DataAreaUIElement)); if (dataAreaUIElement is null) return false; var scrollBarUIElement = dataAreaUIElement.GetDescendant(typeof(ColScrollbarUIElement)); // For VerticalScroll Use RowScrollbarUIElement return scrollBarUIElement != null; }
This code snippet has some wired behavior and doesn't work every time (returns false in some cases)
For now I have assumed a hardcoded number (also not a good approach as different screen DisplayLayout.AutoFitStyle = Columns.Count > 8 ? AutoFitStyle.None : AutoFitStyle.ResizeAllColumns;
Is there a dynamic way of solving the problem?
PS: The user can resize the width of the column anytime
Hello and thank you for contacting Infragistics. I suggest using AutoFitStyle.ExtendLastColumn to fill up the remaining blank space within the grid area as this will not resize any other column but the last one. This was added to resolve this type of request. If this nor ResizeAllColumn is not an option then you'll have to calculate the width of the grid and subtract it from the total width of each column. There isn't a property that will shrink the grid down to fit the width of the columns. I suggest submitting a new product idea.
You can suggest new product ideas for future versions (or vote for existing ones) at <www.infragistics.com/.../ideas>. Submitting your idea will allow you to communicate directly with our product management team, track the progress of your idea at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you. Remember when submitting your idea to explain the context in which a feature would be used and why it is needed as well as anything that would prevent you from accomplishing this today. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it.
Let me know if you have any questions.