Home - Forums-.NET - FlyGrid.Net (Windows Forms) - ColSizing Problem when column is added

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

ColSizing Problem when column is added
Link Posted: 19-Jun-2006 13:04
Hi,

I still have a problem with colum width when columns with FitMode.Spring are added:

http://www.kingvest.de/bugs/colsizing/colsizing.html

Any idea?
Link Posted: 22-Jun-2006 00:45
Do you removing or hide columns?
Can you provide me with code of removing(or hide) columns?
I've tried to reproduce this problem by hide, removing columns, with and without BeginInit/EndInit pair but columns is resized correctly.

Here is my testing sample
Link Posted: 22-Jun-2006 01:00
I remove it:


        void OnColumnRemoved(BaseGridColumn column, GridLayout gridLayout, Guid controllerID)
        {
            if (this.gridLayout == gridLayout && this.controllerID == controllerID)
            {
                this.Columns.Items.Remove(this.Columns.FieldMapColumnFromFieldName(column.FieldName));

                RebuildColumnCache();
            }
        }

        private void RebuildColumnCache()
        {
            columnCache.Clear();

            foreach (Column c in this.Columns.Items)
            {
                if (c.Visible)
                    columnCache.Add(c.FieldName, this.Columns.FieldMapIndexOf(c));
                else
                    columnCache.Add(c.FieldName, this.Columns.GetColumnIndex(c));
            }

            if (ColumnCacheChanged != null)
                ColumnCacheChanged();
        }
Link Posted: 22-Jun-2006 01:01
but actually .. in this sample it happens when I add a column not when I remove it .. here is my add code:

        void OnColumnAdded(BaseGridColumn column, GridLayout gridLayout, Guid controllerID)
        {
            if (this.gridLayout == gridLayout && this.controllerID == controllerID)
            {
                column.ForeColor = Colors.FontDefault;
                column.FitMode = ColumnFitMode.Spring;
                column.ContextMenu = columnsContextMenu;
                column.TextAlign = column.CaptionAlign;

                this.BeginInit();
                if (columnCache.ContainsKey(\"strike\"))
                {
                    if (column.FieldName.StartsWith(\"call\"))
                    {
                        this.Columns.Items.Insert(this.Columns.GetColumnIndexFromFieldName(\"strike\"), column);
                    }
                    else
                    {
                        this.Columns.Items.Insert(this.Columns.GetColumnIndexFromFieldName(\"strike\") + 1, column);
                    }
                }
                else
                {
                    this.Columns.Items.Add(column);
                }
                this.EndInit();

                RebuildColumnCache();
            }
        }