Thread ID:

Created:

Updated:

Platform:

Replies:

I have a PivotGid where certain columns resize to fit after the users changes the grid fields with the PivotTableFieldList. I got this working using the TableModel.ColWidthsChanged event, but maybe there is another event better suited for this??

My problem: the ResizeToFit command still makes the row expander columns too small -> is there a way to force this command to create more space??

I have this code linked to a button which gives the result I want EXCEPT that I would like this linked to an event and not to a button:

With RbrStandenPivot If .PivotRows.Count > 0 Then .TableModel.ColWidths.ResizeToFit(GridRangeInfo.Cols(1, .PivotRows.Count), GridResizeToFitOptions.NoShrinkSize) End If

For ColNo = 1 To .PivotRows.Count Dim OldWidth As Integer = .TableControl.GetColWidth(ColNo) .TableControl.SetColWidth(ColNo, ColNo, OldWidth + 50) Next End With

I have tried several events, but either the changes are overruled or recursion occurs with an error...

In order to change the width when make the changes in PivotTableFieldList, you can use the PivotSchemaDesigner.SchemaChanged property. If you try to change the Column widths ColWidthsChanged event this event triggers recursively so do not use this event to change the column widths. Please refer the below code example and refer the attached sample,

I use the PivotSchemaDesigner.SchemaChanged event to track changes in the grid initiated by the user, including changes in the filter expressions (see my question with ID 128972)

NB: the SchemaChanged event only works with the ShowPivotTableFieldList set to true BUT now I use the PivotRows.CollectionChanged event to track changes to the rows and apply the ResizeToFit solution (whether the PivotTableFieldList is visible or not).

The PivotRows.CollectionChanged event does not work the way I thought (the ResizeToFit gets overuled afterwards) -> BUT I worked around this by adding the ResizeToFit solution to the PivotRows.CollectionChanged handler (when the PivotTableFieldList is visible and the user chooses the fields).

When the PivotTableFieldList is disabled (and the code determines the fields) I use the QueryColWidth event so set to widths. NB: I remove / add the handler for this event when the PivotTableFieldList is enabled / disabled.

In order to achieve your scenario, you can use the Boolean variable in PivotSchemaChanged event to check whether PivotSchema changed or not. If you disable the PivotTableFieldList, the PivotSchemaDesigner is null so you can check this that property in QueryColWidth event. So no need to remove(unwire) the QueryColWidth event handler. Please refer the below code example and refer the below attached sample,

Thank you for your suggestion, it certainly helps to better understand how the events are linked.

Unfortunately an error occurs when I add: AddHandlerMe.pivotGridControl1.PivotSchemaDesigner.SchemaChanged, AddressOf PivotSchemaDesigner_SchemaChanged when the ShowPivotFieldTableList is FALSE. The handler seems only to work with the PivotTableFieldList visible -> but it is no problem to wire and unwire this eventhandler....

But I am fine with how it works now!

BTW: I added the ResizeToFit command to the PivotSchemaDesigner.SchemaChanged event (and not like I wrote to the PivotRows.CollectionChanged handler -> I should not post stuff when I am in a hurry :( )