Home Forums WPF controls Xceed DataGrid for WPF Defining columns order

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

    Hi,
    I am binding my grid control to an observable collection (in code), and I have problems with the columns order. My collection contains 4 members: “Name”, “Type”, “X”, “Y”. (this is the order which I want in my grid).
    The problem is that the columns are ordered differentelly (“Type”, “X”, “Y”, “Name”).
    How can I control the columns order ?

    Here is my code:
    namespace GridTest
    {
    public partial class Window1
    {

    ObservableCollection<MyGridRow> mRowsCollection = new ObservableCollection<MyGridRow>();

    public Window1()
    {
    this.InitializeComponent();

    // Insert code required on object creation below this point.
    }

    private void WindowLoaded(object sender, RoutedEventArgs e)
    {
    MyGrid.ItemsSource = mRowsCollection;

    MyGridRow aGridRow = new MyGridRow();
    aGridRow.Name = “Paul”;
    aGridRow.Type = “Driver”;
    aGridRow.X = “11”;
    aGridRow.Y = “30”;
    mRowsCollection.Add(aGridRow);
    }

    }

    public class MyGridRow
    {
    private string _Name;
    private string _Type;
    private string _X;
    private string _Y;

    public string Name
    {
    get { return _Name; }
    set { _Name = value; }
    }
    public string Type
    {
    get { return _Type; }
    set { _Type = value; }
    }
    public string X
    {
    get { return _X; }
    set { _X = value; }
    }
    public string Y
    {
    get { return _Y; }
    set { _Y = value; }
    }
    }
    }

    Imported from legacy forums. Posted by Yoav (had 1822 views)

    Xceed Support
    Member
    Post count: 5658

    You can set a column’s VisiblePosition property to define the order in which you want them to be displayed.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 2966 views)

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