James King - 2020-06-20

I'm trying to quickly modify the default enum editor so that it only displays certain values (the enum has about 10 values, but on each row of my OLV only 2-3 values need to be available, depending on the other data)

I'm just trying to get something functional and I'll probably come back to this to make it nicer in the future, for now I just want it to work

I've used a delegate to set up a new combobox which I've populated the way I need, but I can't get a value back from it - I've used an aspectputter to try and solve this, and the newvalue I'm getting back is null every time. I'm guessing this is because there's no Value property on the combobox, and the Text property doesn't return the selected item in dropdownlist mode either.

Is there a quick and easy way around this or am I going to have to create a custom control to make this work?

code looks a bit like this

ObjectListView.EditorRegistry.Register(typeof(MatchType), delegate (Object obj, OLVColumn col, Object value)
{
    ComboBox box = new ComboBox();
    box.DropDownStyle = ComboBoxStyle.DropDownList;

    // populate combobox
    Data m = (Data)obj;

    if (m.condition1)
        box.Items.Add("Option1");

    if (m.condition2)
        box.Items.Add("Option2");

    //etc

    return box;

});

column.AspectPutter = delegate (object model, object newValue) {
    Data m = (Data)model;
    string s = (string)newValue;      // this is null every time
    m.Thing = s;                      
};
 

Last edit: James King 2020-06-20