How to Change Row Height and Column Width

how can I manually set in XML or code behind width for Columns?


1 Reply

VS Vijayarasan Sivanandham Syncfusion Team May 9, 2022 03:13 PM UTC

Hi Patrycja,

Your requirement to set the column width and row height by using the PivotGrid.InternalGrid.ColumnWidth and PivotGrid.InternalGrid.RowHeights propertylike below mentioned code snippet,

private void OnAllColumnWidthAndRowHeightClicked(object sender, RoutedEventArgs e)

{

            var getRowCount = pivotGrid1.InternalGrid.Model.RowCount;

 

            //here define the row height for all rows in PivotGrid

            for (int i = 0; i < getRowCount; i++)

                pivotGrid1.InternalGrid.RowHeights[i] = 100;

 

 

            //here define the column width for all column in PivotGrid

            var getColumnCount = pivotGrid1.InternalGrid.Model.ColumnCount;

            for (int i = 0; i < getColumnCount; i++)

                pivotGrid1.InternalGrid.ColumnWidths[i] = 100;

 

            pivotGrid1.InternalGrid.InvalidateVisual();

}

 

private void OnSpecificColumnWidthAndRowHeightClicked(object sender, RoutedEventArgs e)

{

            //here set the Row height for 5th row in pivotGrid

            pivotGrid1.InternalGrid.RowHeights[4] = 100;

            //here set the Row height for 2nd column in pivotGrid

            pivotGrid1.InternalGrid.ColumnWidths[1] = 100;

            pivotGrid1.InternalGrid.InvalidateVisual();

}


UG Link: https://help.syncfusion.com/wpf/pivot-grid/how-to/resizing-columns-and-rows-in-pivotgrid

KB Link: https://www.syncfusion.com/kb/2948/how-to-adjust-the-width-for-each-column

https://www.syncfusion.com/kb/2894/how-to-scale-the-pivot-grid-columns-and-rows-to-the-size-of-the-window

Please find the sample in the attachment and let us know if you have any concerns in this.


Regards,

Vijayarasan S


Attachment: PivotGridControlDemo_ff51787e.zip

Loader.
Up arrow icon