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
120
column swapping
posted

Is there a way to turn on column swapping for some of the columns in a band, but not all of the columns?  Using the UltraWinGrid designer, under the "Column Swapping" feature I selected the option "Within Band Only".  However, I don't want the first column in the band to be moved, but I would like to allow other columns to be moved with the little drop down that appears.  How do I accomplish this?

Thanks,

David

Parents
No Data
Reply
  • 45049
    posted

    There's no setting on the column itself, but I think you can do this with some event handling.  I haven't tested the below C# code, but it's what I'd try:

    using Infragistics.Win.UltraWinGrid;
    ...
    protected virtual void ultraGrid1_AfterColPosChanged(object sender, BeforeColPosChangedEventArgs e)
    {
        // Is this a swap action?
        if (e.PosChanged == PosChanged.Swapped)
        {
            // Look through all the columns affected
            foreach (ColumnHeader header in e.ColumnHeaders)
            {
                // Is the first column affected?
                if (header.Column.Index == 0)
                {
                    // Cancel the event and leave the event handler
                    e.Cancel = true;
                    return;
                }
            }
        }
    }

    What this doesn't do is prevent the first column from showing up in the swapping drop-down, and I don't immediately see how to do that.

Children
No Data