XPTable.Models.Table.GetAutoColumnWidthWithMode C# (CSharp) Method

GetAutoColumnWidthWithMode() private method

Returns the new column width if the columns resize mode allows it to be changed. Returns 0 if it should not be changed.
private GetAutoColumnWidthWithMode ( Column column, int maxwidth ) : int
column Column
maxwidth int
return int
        int GetAutoColumnWidthWithMode(Column column, int maxwidth)
        {
            int changedWidth = 0;
            int oldwidth = column.Width;

            switch (column.AutoResizeMode)
            {
                case ColumnAutoResizeMode.Any:
                    // Always allow the change
                    changedWidth = maxwidth;
                    break;
                case ColumnAutoResizeMode.Shrink:
                    // Only allowed if the new width is smaller
                    if (maxwidth < oldwidth)
                        changedWidth = maxwidth;
                    break;
                case ColumnAutoResizeMode.Grow:
                    // Only allowed if the new width is greater
                    if (maxwidth > oldwidth)
                        changedWidth = maxwidth;
                    break;
            }

            return changedWidth;
        }
Table