Hi,
I previously made a post asking about the multiline display for a single row. It worked fine in my mini project. But now that i want to implement that feature into the main software, i get some weird behavior.
I found a work around to my problem by calling PerformAutoSize() 2 times to get the expected result, else it doesnt work. :(
foreach (UltraGridRow row in e.Layout.Rows.All){ row.PerformAutoSize();row.PerformAutoSize();}
Maybe you can see the problem already there but i will be adding codes that happen in the event InitializeLayout. I tried to get the most related lines of code. Here it is :
this.SuspendLayout(); this.BeginUpdate();
e.Layout.CaptionVisible = DefaultableBoolean.False; e.Layout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.None; e.Layout.Override.RowSelectors = DefaultableBoolean.False; e.Layout.Override.ActiveAppearancesEnabled = DefaultableBoolean.False; e.Layout.Bands[0].Override.AllowAddNew = AllowAddNew.No; e.Layout.Bands[0].Override.AllowDelete = DefaultableBoolean.False; e.Layout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; this.DisplayLayout.Override.WrapHeaderText = DefaultableBoolean.True; e.Layout.Bands[0].Override.AllowRowLayoutCellSizing = RowLayoutSizing.Both; e.Layout.Bands[0].Override.CellClickAction = CellClickAction.CellSelect; e.Layout.Bands[0].Override.SelectTypeCell = SelectType.Extended; e.Layout.Override.HeaderClickAction = HeaderClickAction.Select; e.Layout.Override.SelectTypeCol = SelectType.None; e.Layout.Override.SelectedCellAppearance = e.Layout.Override.HotTrackHeaderAppearance; e.Layout.ScrollStyle = ScrollStyle.Immediate;
foreach (UltraGridColumn column in this.DisplayLayout.Bands[0].Columns) { if (column.Tag is IEntete) { IEntete entete = (IEntete)column.Tag; if (column.Width < entete.EnteteSource.TO.Largeur || entete.EnteteSource.TO.Largeur == column.MinWidth) column.RowLayoutColumnInfo.PreferredCellSize = new Size(entete.EnteteSource.TO.Largeur, column.RowLayoutColumnInfo.PreferredCellSize.Height); } }
this.DisplayLayout.Bands[0].RowLayoutStyle = RowLayoutStyle.ColumnLayout;
e.Layout.Override.RowSizing = RowSizing.Free; foreach (UltraGridColumn column in e.Layout.Bands[0].Columns) { column.AutoSizeEdit = Infragistics.Win.DefaultableBoolean.True; column.CellMultiLine = Infragistics.Win.DefaultableBoolean.True; }
foreach (UltraGridRow row in e.Layout.Rows.All) { row.PerformAutoSize(); row.PerformAutoSize(); }
this.EndUpdate();this.ResumeLayout();
If you want more info on my problem, i can send more code. Note : I don't use any events that could interact with the UltraGrid other than the InitializeLayout.
Thanks!
Hi Luke,
I just wanted to let you know that we found the bug and it will be fixed in the next service release scheduled for November (after the release of NetAdvantage 11.2).
But also, while fixing this, we discovered that it works fine if you set RowSizing to AutoFree instead of Free. In fact, even with the fix, using AutoFree will be better (slightly more efficient) than using Free, anyway.
Luke,
I have submitted this issue to our development team. You will receive more information on this through the support case.
Thx! Happy to hear we found a bug :D
Luke111 said:If this is forcing the cells to be created too early, why no exception?
I don't think this is something we could catch with an exception, and it's not necessarily an invalid thing to do in every case.
Luke111 said:I looked in the infragistic documentation and they are using BOTH RowLayoutStyle and CellDisplayStyle inside the InitializeLayout event. Even modifying a cell !!!! Word for word from the documentation!!! "// It can be also set on an individual cell." Here are the links : http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v11.1~Infragistics.Win.UltraWinGrid.UltraGridColumn~CellDisplayStyle.htmlhttp://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/HTML/Infragistics2.Win.UltraWinGrid.v11.1~Infragistics.Win.UltraWinGrid.UltraGridBand~RowLayoutS
// It can be also set on an individual cell."
Clearly the problem here is being caused by the combination of both settings, not just one by itself.
Luke111 said:Even if i don't touch the cells, I still get the same problem with this : this.ultraGrid1.DisplayLayout.Bands[0].RowLayoutStyle = RowLayoutStyle.ColumnLayout;
Are you saying that if you download the sample you attached here and remove the code that loops through the cells, it still doesn't size the row properly?
I tried it again just to make sure and it works fine for me. So if that is not working for you, then my only suggestion is that you make sure you have the latest service release.
How to get the latest service release - Infragistics Community
Luke111 said:I dont get my multiline, is the RowLayoutStyle needed in InitializeRow??
As a general rule, the RowLayoutStyle, or any property that applies to a column, band, or override should be applied in InitializeLayout.
Properties that affect individual rows or cells are better set in the InitializeRow event.
Luke111 said: It is similar to what is inside the documentation. Why not working? And here is the code : private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { this.ultraGrid1.SuspendLayout(); this.ultraGrid1.BeginUpdate(); this.ultraGrid1.DisplayLayout.Override.CellMultiLine = DefaultableBoolean.True; this.ultraGrid1.DisplayLayout.Bands[0].RowLayoutStyle = RowLayoutStyle.ColumnLayout; e.Layout.Override.RowSizing = RowSizing.Free; this.ultraGrid1.EndUpdate(); this.ultraGrid1.ResumeLayout(); } private void ultraGrid1_AfterColPosChanged(object sender, AfterColPosChangedEventArgs e) { foreach (UltraGridRow row in this.ultraGrid1.Rows.All) { //This line doesnt work. row.PerformAutoSize(); } } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { //This line doesnt work. e.Row.PerformAutoSize(); } }
It is similar to what is inside the documentation. Why not working? And here is the code :
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { this.ultraGrid1.SuspendLayout(); this.ultraGrid1.BeginUpdate(); this.ultraGrid1.DisplayLayout.Override.CellMultiLine = DefaultableBoolean.True; this.ultraGrid1.DisplayLayout.Bands[0].RowLayoutStyle = RowLayoutStyle.ColumnLayout; e.Layout.Override.RowSizing = RowSizing.Free; this.ultraGrid1.EndUpdate(); this.ultraGrid1.ResumeLayout(); } private void ultraGrid1_AfterColPosChanged(object sender, AfterColPosChangedEventArgs e) { foreach (UltraGridRow row in this.ultraGrid1.Rows.All) { //This line doesnt work. row.PerformAutoSize(); } } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { //This line doesnt work. e.Row.PerformAutoSize(); } }
I tried replacing the code in your sample with this code, and now I see the same problem without accessing the cells. This seems like a bug to me, so I am going to send the modified sample over to Infragistics Developer Support so they can write this up for developer review and get it looked into.