The following code attempts to size a one column Ultragrid to the size as it's column after executing a PerformAutoResize. The column is filtered with each key typed into uxInput. The problem is that the filter works but the PerformAutoResize is based on the pre-filtered list. What am I missing?
Thanks,Jeremy
Private Sub OnInput_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxInput.ValueChanged
With uxSuggestionList.Rows.ColumnFilters(0) .ClearFilterConditions() If Not String.IsNullOrEmpty(uxInput.Text) Then Dim column As UltraGridColumn = uxSuggestionList.DisplayLayout.Bands(0).Columns(0) .FilterConditions.Add(New FilterCondition(column, FilterComparisionOperator.Contains, uxInput.Text)) End If End With
column.PerformAutoResize() uxSuggestionList.Width = column.Width
End Sub
Hi,
When you call the parameterless overload of PerformAutoResize, I think it's supposed to just size the visible rows. So I would think this should work. Unless maybe you are also setting ColumnAutoSizeMode and the PerformAutoResize is falling back to that property as the default.
Try explicitly specifying only visible rows:
column.PerformAutoResize(PerformAutoSizeType.VisibleRows) and see if that helps.
If not, then my guess is that it's because filtering is done asynchronously, so the rows aren't filtered out until the next time the grid paints, which means the rows will actually be visible when you call PerformAutoResize. I'm not sure there is any way around that, but you might be able to handle the BeforeRowFilterChanged event and set e.ProcessMode to Synchronous. Assuming this event fires when you add a filter programmatically, this will force the filtering to be done synchronously and that might work if I am right about this.
If none of that works, I recommend that you Submit an incident to Infragistics Developer Support so they can check it out.
Hi Mike.
Your assumption about asynchronous filtering appears to be correct. However, setting e.ProcessMode to Synchronous in the BeforeRowFilterChanged has no effect. Also, BeforeRowFilterChanged doesn't fire when a filter is set programatically (a bug in and of itself) so I testing by enabling the manual filter row.
Okay, I tried this out and I got it to work. What you do is, right before you call PeformAutoResize, call:
grid.DisplayLayout.UIElement.VerifyChildElements()
Hi, I noticed the same problem. Tried suggested solution but... After grid has been filtered, PerformAutoResize(10000) calculates columns width considering ALL rows, filtered out ones too. I don't want to use PerformAutoSizeType.VisibleRows, because it seems to calculate on displayed on screen rows ONLY, it means that if you scroll down on rows that were over displaying area when you called PerformAutoResize, you'll find that rows not correctly resized... Could anyone help me? It is very frustrating... Bye Gianni
Hi Gianni,
There is no option to only include non-hidden rows as far as I know. You should Submit a feature request to Infragistics
Hi, I submitted a feature request.
Anyway, thank you Mike for your fast reply.
ByeGianni