Home Forums WinForms controls Xceed Grid for WinForms drag column off grid Reply To: drag column off grid

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)