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,
I've attached the source to my app as a .zip file. The upload was limited to 200k, so I had to remove the obj and bin directories. You will have to rebuild before you can run it. I'm sure your references are in different locations, so you will have to update them accordingly for it to build/run. Please let me know what you find.
Thanks
Dan
I guess that I misunderstood what you meant in your first reply. I thought you were saying that the grid columns could be resized based on the window being resized, but that your example did not represent a real world scenario.
I could not find an AutoSize property, did you mean AutoFit?
What I’m trying to do is have a grid that has some columns which are of a fixed width, and the other columns that occupy the remaining space. The window is resizable, therefore, the amount of remaining space changes whenever the widow is resized. Should I try to achieve this in a different manner?
"DanSuitor" wrote in message news:24669@forums.infragistics.com... Joe, I guess that I misunderstood what you meant in your first reply. I thought you were saying that the grid columns could be resized based on the window being resized, but that your example did not represent a real world scenario. This IS what I was saying - but the sample I provided simply added a fixed value to the width of the first column - exactly what you are doing in the sample you provided. I could not find an AutoSize property, did you mean AutoFit? Yes - sorry about that. I did mean AutoFit. What I'm trying to do is have a grid that has some columns which are of a fixed width, and the other columns that occupy the remaining space. The window is resizable, therefore, the amount of remaining space changes whenever the widow is resized. Should I try to achieve this in a different manner? No - you can achieve this in the same basic manner as the code your provided - i.e., override OnRenderSizeChanged and manipulate the Cell width. You just have to iterate over all the fields as you are doing in the code that is currently 'ifdeffed' out as a result of TEST_BASED_ON_SAMPLE_CODE and refine your width calculations. Dan http://forums.infragistics.com/forums/p/5092/24669.aspx#24669
This IS what I was saying - but the sample I provided simply added a fixed value to the width of the first column - exactly what you are doing in the sample you provided.
Yes - sorry about that. I did mean AutoFit.
What I'm trying to do is have a grid that has some columns which are of a fixed width, and the other columns that occupy the remaining space. The window is resizable, therefore, the amount of remaining space changes whenever the widow is resized. Should I try to achieve this in a different manner?
No - you can achieve this in the same basic manner as the code your provided - i.e., override OnRenderSizeChanged and manipulate the Cell width. You just have to iterate over all the fields as you are doing in the code that is currently 'ifdeffed' out as a result of TEST_BASED_ON_SAMPLE_CODE and refine your width calculations.
No - you can achieve this in the same basic manner as the code your provided - i.e., override OnRenderSizeChanged and manipulate the Cell width. You just have to iterate over all the fields as you are doing in the code that is currently 'ifdeffed' out as a result of
TEST_BASED_ON_SAMPLE_CODE
and refine your width calculations.
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.
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
Attached is the grid test app.