ColumnHeaderClick in Rhino6

eto
rhino6

#1

Hi guys,

I’m using ColumnHeaderClick events to sort GridView columns. Works fine in the Rhino-5 plugin (referencing Eto & Eto.Wpf 2.4.1), but the events don’t seem to fire from Rhino-6. Has something changed? I see the Rhino-6 Eto libs have been incremented (2.4.6664.1688), but don’t see any documentation of this build online.

Cheers,

Jon


(Dale Fugier) #3

Hi @Jon,

Something like this works here:

var grid = new GridView
{
  AllowColumnReordering = false,
  AllowMultipleSelection = false,
};

grid.BindDataContext(c => c.DataStore, (TestViewModel m) => m.Objects);

grid.SelectionChanged += (sender, args) =>
{
  // TODO...
};

grid.ColumnHeaderClick += (sender, e) =>
{
  // TODO...
};

Perhaps we need to see some sample code that isn’t working for you?

– Dale


#4

Thanks, Dale. Here’s some example code.

var items = new List<MyItem>
{
    new MyItem { Name = "item1", Prop_1 = "some val" },
    new MyItem { Name = "item2", Prop_1 = "some val" }
};
var grid = new MyGrid(items);

where

public class MyGrid : GridView
{
    public MyGrid(List<MyItem> items)
    {
        // properties
        GridLines = GridLines.Horizontal;
        AllowColumnReordering = false;
        AllowMultipleSelection = false;
        DataStore = new ObservableCollection<MyItem>(items);

        // columns
        Columns.Add(new GridColumn
        {
            DataCell = new TextBoxCell { Binding = Binding.Property<MyItem, string>(r => r.Name) },
            HeaderText = "Name"
        });
        Columns.Add(new GridColumn
        {
            DataCell = new TextBoxCell { Binding = Binding.Property<MyItem, string>(r => r.Prop_1) },
            HeaderText = "Property 1"
        });

        // row selection
        SelectionChanged += (s, e) =>
        {
            MessageBox.Show("this fires");
        };

        // column sorting
        ColumnHeaderClick += (s, e) =>
        {
            MessageBox.Show("this fires in Rhino 5 (Eto 2.4.1), but not 6 (Eto 2.4.6...)");
        };
    }
}

and

public class MyItem
{
    internal string Name { get; set; }
    internal string Prop_1 { get; set; }
    internal MyItem() { }
}

Thanks.

-Jon


(Curtis Wensley) #6

Hi @Jon,

Sorry for the late reply, but you need to set GridColumn.Sortable = true for the ColumnHeaderClick event to fire.

The Eto that is included with Rhino is a custom build based on the develop branch on GitHub, since that allows us to get fixes into Rhino quicker.

Hope this helps!
Curtis.


#7

Perfect, thanks Curtis!