Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
UltraGridRow, strange behavior from PerformAutoSize() ?
posted

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.