Hi,
I have ultra grid .The grid initialy dragged to cover whole form.The grid may contain 5 or 50 or 100 rows
depend on the condition.If it contain 5 rows the ultragrid have to shrink to fit to the content
ie There must be no space between ultra grid border and rows
PLz Tell is there any property to do it
thanks in advance
No, there's currently no way to do this. You could try to calculate the grid's height based on the rows, but it's pretty tricky. You would need to account for the column headers, scrollbars, rows, and borders.
Thanks Mike I will try and let u know
Did anyone eventually get this working?
I have the same need.
Thank you so much.
Set the Dock Property to Fill then if the Vertical Scroll Bar is Visible you have to calculate the Datagrid height like Mike Saltzman suggested.
I have actually done this, following Saltzman's suggestion. The problem is that I am setting the .DataSource to a DataTable (with only 10 rows and 6 columns), and it takes 50 milliseconds to calculate the height per row for a total time of about half a second per grid. I since sped it up by only calculating the first row height and multiplying by the number of rows, but 50ms is ridiculously slow. And thats only the row height. Adding the column widths is not quite as slow, but is still an incremental 60ms. All-in, my best implementation of a shrinktofit routine takes about 150ms per grid.
While this is acceptable for my current application (and in general I will only be shrinking to fit small grids anyway), this is not a scalable solution for when I plan only having 20 grids on my screen. These 20 grids would take 150ms * 20 = 3 seconds just to figure out what height and width the grid should be.
I am still looking for a better method. Please let me know if anyone finds one!
Hello all,
I tried this with 50 rows and 6 columns and the execution of the code every time was about 1ms. So could you please review the sample attached to this post and see if it meets your requirements.
Please feel free to let me know if I misunderstood you or if you have any other questions.