src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/UI/ColumnHeader.cs
/// <summary>
///     Specify the column headers for this control. Headers are in the order
///     of the native columns, not the current ColumnPermutation. The number
///     of items in the header must match the number of columns in the current
///     tree or multi-column tree.
/// </summary>
/// <param name="headers">An array of headers, with ascending perctages as specified in the VirtualTreeColumnHeader documentation.</param>
/// <param name="calculatePercentage">true if the percentages for non-fixed width columns should be divided evenly among all proportional headers.</param>
Specify the column headers for this control. Headers are in the order
of the native columns, not the current ColumnPermutation. The number
of items in the header must match the number of columns in the current
tree or multi-column tree.
Specify the column headers for this control . Headers are in the order of the native columns not the current ColumnPermutation . The number of items in the header must match the number of columns in the current tree or multi - column tree .
public void SetColumnHeaders(VirtualTreeColumnHeader[] headers, bool calculatePercentage)
        {
            if (headers == null
                || headers.Length == 0)
            {
                if (myFullHeaders != null)
                {
                    myFullHeaders = null;
                    PermuteHeaders(null, myColumnPermutation, false, -1);
                    RedrawHeaderFrame();
                }
                return;
            }
            var columnCount = (myMctree == null) ? ((myTree == null) ? 0 : 1) : myMctree.ColumnCount;
            if (columnCount == 0)
            {
                columnCount = headers.Length;
            }
            else if (headers.Length != columnCount)
            {
                throw new ArgumentException(VirtualTreeStrings.GetString(VirtualTreeStrings.HeaderArrayException), "headers");
            }
            if (calculatePercentage)
            {
                var proportionalCount = 0;
                for (var i = 0; i < columnCount; ++i)
                {
                    if (headers[i].Percentage != 0f)
                    {
                        ++proportionalCount;
                    }
                }
                var percentIncrement = (float)1 / proportionalCount;
                var percent = 1f;
                for (var i = columnCount - 1; i >= 0; --i)
                {
                    if (headers[i].Percentage != 0f)
                    {
                        headers[i].SetPercentage(percent);
                        percent -= percentIncrement;
                    }
                }
            }
            else
            {
                var prevVariableColumn = -1;
                float percent;
                var prevPercent = 0f;
                for (var i = 0; i < columnCount; ++i)
                {
                    percent = headers[i].Percentage;
                    if (percent != 0)
                    {
                        if (percent <= prevPercent)
                        {
                            throw new ArgumentException(
                                VirtualTreeStrings.GetString(VirtualTreeStrings.PercentageBasedHeadersInvalidException), "headers");
                        }
                        prevPercent = percent;
                        prevVariableColumn = i;
                    }
                }
                if (prevVariableColumn != -1
                    && prevPercent != 1f)
                {
                    throw new ArgumentException(
                        VirtualTreeStrings.GetString(VirtualTreeStrings.PercentageBasedHeadersLastInvalidException), "headers");
                }
            }
            var frameChange = myFullHeaders == null;
            myFullHeaders = headers;
            var oldSelectionColumn = mySelectionColumn;
            if (oldSelectionColumn >= 0
                && myColumnPermutation != null)
            {
                oldSelectionColumn = myColumnPermutation.GetNativeColumn(oldSelectionColumn);
            }
            PermuteHeaders(null, myColumnPermutation, false, oldSelectionColumn);
            if (frameChange && DisplayColumnHeaders)
            {
                SetStyleFlag(VTCStyleFlags.DisplayColumnHeaders, false);
                DisplayColumnHeaders = true;
            }
        }
public void SetColumnHeaders ( VirtualTreeColumnHeader [ ] headers , bool calculatePercentage ) { if ( headers == null || headers . Length == 0 ) { if ( myFullHeaders != null ) { myFullHeaders = null ; PermuteHeaders ( null , myColumnPermutation , false , - 1 ) ; RedrawHeaderFrame ( ) ; } return ; } var columnCount = ( myMctree == null ) ? ( ( myTree == null ) ? 0 : 1 ) : myMctree . ColumnCount ; if ( columnCount == 0 ) { columnCount = headers . Length ; } else if ( headers . Length != columnCount ) { throw new ArgumentException ( VirtualTreeStrings . GetString ( VirtualTreeStrings . HeaderArrayException ) , " " ) ; } if ( calculatePercentage ) { var proportionalCount = 0 ; for ( var i = 0 ; i < columnCount ; ++ i ) { if ( headers [ i ] . Percentage != 0f ) { ++ proportionalCount ; } } var percentIncrement = ( float ) 1 / proportionalCount ; var percent = 1f ; for ( var i = columnCount - 1 ; i >= 0 ; -- i ) { if ( headers [ i ] . Percentage != 0f ) { headers [ i ] . SetPercentage ( percent ) ; percent -= percentIncrement ; } } } else { var prevVariableColumn = - 1 ; float percent ; var prevPercent = 0f ; for ( var i = 0 ; i < columnCount ; ++ i ) { percent = headers [ i ] . Percentage ; if ( percent != 0 ) { if ( percent <= prevPercent ) { throw new ArgumentException ( VirtualTreeStrings . GetString ( VirtualTreeStrings . PercentageBasedHeadersInvalidException ) , " " ) ; } prevPercent = percent ; prevVariableColumn = i ; } } if ( prevVariableColumn != - 1 && prevPercent != 1f ) { throw new ArgumentException ( VirtualTreeStrings . GetString ( VirtualTreeStrings . PercentageBasedHeadersLastInvalidException ) , " " ) ; } } var frameChange = myFullHeaders == null ; myFullHeaders = headers ; var oldSelectionColumn = mySelectionColumn ; if ( oldSelectionColumn >= 0 && myColumnPermutation != null ) { oldSelectionColumn = myColumnPermutation . GetNativeColumn ( oldSelectionColumn ) ; } PermuteHeaders ( null , myColumnPermutation , false , oldSelectionColumn ) ; if ( frameChange && DisplayColumnHeaders ) { SetStyleFlag ( VTCStyleFlags . DisplayColumnHeaders , false ) ; DisplayColumnHeaders = true ; } }
Specify the column headers for this control.
Specify the column headers for this control .
// First count the non-fixed width columns // Having the variable header items be an ascending sequence is critical to // all of the header routines. Make sure that this is the case here. // The headers are turn for a created control in on the DisplayColumnHeaders setter. Fake it out // by first setting the value to false so we can use this code.
headers
VirtualTreeColumnHeader[]
An array of headers, with ascending perctages as specified in the VirtualTreeColumnHeader documentation.
An array of headers with ascending perctages as specified in the VirtualTreeColumnHeader documentation .
calculatePercentage
bool
true if the percentages for non-fixed width columns should be divided evenly among all proportional headers.
true if the percentages for non - fixed width columns should be divided evenly among all proportional headers .