Showing a dynamic list of values in ComboBoxCell

121 views
Skip to first unread message

Andreas Wäscher

unread,
Apr 5, 2017, 3:16:43 AM4/5/17
to Eto.Forms

I want to add a ComboBoxCell showing a value with a dropdown of other possible values. 

The thing is, that the possible values differ for each row in my grid view, so an approach like this will not work.


grid.Columns.Add(new GridColumn
{
    DataCell = new ComboBoxCell
    {
        Binding = Binding.Property<MyPoco, object>(r => r.AnyValue), // ok
        DataStore = new string[] { "abc", "def", "ghi" } // static
    }
});


So I think I might need any expression like used for the Binding, like so ...


grid.Columns.Add(new GridColumn
{
    DataCell = new ComboBoxCell
    {
        Binding = Binding.Property<MyPoco, object>(r => r.AnyValue), 
        DataStore = Binding.Property<MyPoco, IEnumerable<string>>(r => r.MyValueList)
    }
});


... but that does not even compile. Does anyone know how to achieve this?

awae...@gmail.com

unread,
Apr 7, 2017, 6:08:26 PM4/7/17
to Eto.Forms

Please feel free to respond to my question on StackOverflow as well, to get some reputation ;)

http://stackoverflow.com/questions/43182456/eto-forms-showing-a-dynamic-list-of-values-in-comboboxcell

Andreas Wäscher

unread,
Apr 14, 2017, 7:28:02 PM4/14/17
to Eto.Forms
Is anyone even awake in here?

curtis

unread,
Apr 18, 2017, 5:16:03 PM4/18/17
to Eto.Forms
Hi Andreas,

Sorry for the late response, but I am very busy with paid work and I don't always have time to respond to questions on the forum right away.

The ComboBoxCell does not support per-row list of items.  However, you could implement this using a CustomCell.  Check out this gist.

Note that there seems to be a problem with using a DropDown on macOS due to the auto size code, so you'd have to set GridColumn.AutoSize = false for it to work correctly.  I've logged a bug for that here.

Hope this helps!
Curtis.

Andreas Wäscher

unread,
Apr 19, 2017, 3:47:30 AM4/19/17
to Eto.Forms
Hi Curtis,

I'm actually quite sorry for being that impatient and of course I see that different things have different priority. Thank you for posting that gist, I'll have a try soon.

Thank you
Andy

Andreas Wäscher

unread,
Apr 19, 2017, 10:53:01 AM4/19/17
to Eto.Forms

Wow, works like a charm. At least in WPF, WinForms does not show a ComboBox. And the custom paint event is not correctly implemented for GTK and WinForms, because painting on Point(0, 0) does not render any text. Instead the ClipRectangle have to be used.
Anyway, pretty happy with that approach, thank you!

curtis

unread,
Apr 21, 2017, 12:52:56 PM4/21/17
to Eto.Forms
To get the ComboBox to show on WinForms or GTK you have to set GridColumn.Editable = true, then click the cell to edit it.

You're right in that you need to use the ClipRectangle to determine where to paint the text, was my silly mistake. (;

Cheers!
Curtis.
Reply all
Reply to author
Forward
0 new messages