Skip to content

DevExpress-Examples/winforms-grid-implement-serializable-column-property

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Data Grid - Implement a serializable property for the grid column

Important

This example uses internal APIs that may change in newer versions.

The VisibleIndex property returns -1 if a column is hidden. This example demonstrates how to implement a serializable property that stores the visible index of a column before the column is hidden. This allows you to save and restore the position of hidden columns when saving/loading the grid layout.

Implementation Details

  • Create a GridColumn descendant (MyGridColumn).

  • Implement a new property and apply the XtraSerializableAttribute attribute:

    private int oldVisibleIndex = -1;
    [XtraSerializableProperty, XtraSerializablePropertyId(LayoutIdLayout)]
    public int OldVisibleIndex {
        get { return oldVisibleIndex; }
        set {
            if (value == -1) return;
            oldVisibleIndex = value; 
        }
    }

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)