I'm trying to resize my column widths whenever the user resizes the window. When the window size changes, I determine the new column widths then apply it to the column and label width properties:
currColField.Settings.CellMinWidth = dWidthPerCol;currColField.Settings.CellMaxWidth = dWidthPerCol;currColField.Settings.CellWidth = dWidthPerCol;
currColField.Settings.LabelMaxWidth = dWidthPerCol;currColField.Settings.LabelMinWidth = dWidthPerCol;currColField.Settings.LabelWidth = dWidthPerCol;
Problem is, the settings don't take cause the columns to resize. Am I doing something wrong? Is there a better way to approach this?
ThanksDan
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { base.OnRenderSizeChanged(sizeInfo); double newCellWidth = this.xamDataGrid1.DefaultFieldLayout.Fields[0].CellWidthResolved + 1; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellMinWidth = newCellWidth; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellMaxWidth = newCellWidth; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellWidth = newCellWidth; double newLabelWidth = this.xamDataGrid1.DefaultFieldLayout.Fields[0].LabelWidthResolved + 1; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelMaxWidth = newLabelWidth; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelMinWidth = newLabelWidth; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelWidth = newLabelWidth; }
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo); double newCellWidth = this.xamDataGrid1.DefaultFieldLayout.Fields[0].CellWidthResolved + 1; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellMinWidth = newCellWidth; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellMaxWidth = newCellWidth; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellWidth = newCellWidth; double newLabelWidth = this.xamDataGrid1.DefaultFieldLayout.Fields[0].LabelWidthResolved + 1; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelMaxWidth = newLabelWidth; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelMinWidth = newLabelWidth; this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelWidth = newLabelWidth;
base.OnRenderSizeChanged(sizeInfo);
double newCellWidth = this.xamDataGrid1.DefaultFieldLayout.Fields[0].CellWidthResolved + 1;
this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellMinWidth = newCellWidth;
this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellMaxWidth = newCellWidth;
this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.CellWidth = newCellWidth;
double newLabelWidth = this.xamDataGrid1.DefaultFieldLayout.Fields[0].LabelWidthResolved + 1;
this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelMaxWidth = newLabelWidth;
this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelMinWidth = newLabelWidth;
this.xamDataGrid1.DefaultFieldLayout.Fields[0].Settings.LabelWidth = newLabelWidth;
}
Joe,
Ok, so we agree that this is possible, and should work. Let me show you what I’m seeing. I’ve attached a jpg with 2 screen shots. The first shows the grid before the window resize, the second after. As you can see, the column widths remain the same between the 2 screen shots. What I was expecting to have happen was as the window grew, the column size for “Field 1” would grow as well. However, it remains unchanged. Since I can only attach 1 file per post, I’ll create a second post through which I’ll upload an updated version of the GridTest project so that you can try this for yourself.
Dan
Attached is the grid test app.
Hi Support Team,I have few columns in XamDataGrid which are able to resize.I 'm trying set minimum width for each column to prevent from minimizing the entire column.Thanks in advance!Vim
Hello Vim,
I found this post duplicate to this one:
http://ko.infragistics.com/community/forums/p/82901/414148.aspx#414148
which is already discussed.