Home Forums WinForms controls Xceed Grid for WinForms drag column off grid

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15849 |

    Is there a way to make a column in-visible by dragging it out of the grid?

    Imported from legacy forums. Posted by troy@querytool.com (had 1972 views)

    Xceed Support
    Member
    Post count: 5658

    You need to override the ColumnManagerCell to implement this (you will also need to override the ColumnManagerRow).

    Here is the code I used:

    <code>
    //The Custom ColumnManagerCell code

    public class MyColumnManagerCell : ColumnManagerCell
    {
    protected MyColumnManagerCell( MyColumnManagerCell template )
    : base( template )
    {
    }

    public MyColumnManagerCell( Column parentColumn )
    : base( parentColumn )
    {
    }

    protected override Cell CreateInstance()
    {
    return new MyColumnManagerCell( this );
    }

    protected override void OnMouseUp( MouseEventArgs e )
    {
    base.OnMouseUp( e );

    Point gridPoint = this.ClientPointToGrid( new Point( e.X, e.Y ) );

    if( !this.GridControl.DisplayRectangle.Contains( gridPoint ) )
    this.ParentColumn.Visible = false;
    }

    }

    //The Custom ColumnManagerRow code
    public class MyColumnManagerRow : ColumnManagerRow
    {
    public MyColumnManagerRow()
    : base()
    {
    }

    protected MyColumnManagerRow( MyColumnManagerRow template )
    : base( template )
    {
    }

    public MyColumnManagerRow( RowSelector rowSelector )
    : base( rowSelector )
    {
    }

    protected override Row CreateInstance()
    {
    return new MyColumnManagerRow( this );
    }

    protected override Cell CreateCell( Column parentColumn )
    {
    return new MyColumnManagerCell( parentColumn );
    }
    }

    private void Form1_Load( object sender, EventArgs e )
    {
    //…
    gridControl1.FixedHeaderRows.Add(new MyColumnManagerRow());
    }
    </code>

    Imported from legacy forums. Posted by CharlesB (had 2968 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.