Home Forums WinForms controls Xceed Grid for WinForms WinComboBox as Editor/Viewer

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

    Hello!

    Any ideas how you successfully implement the ICellEditor and ICellViewer interfaces so that you can use a WinComboBox with the grid? I’ve successfully (and quite painlessly) implemented the interfaces for WinCheckBox as well as WinDatePicker, but WinComboBox is leaving me clueless. I think it’s the SetControlValue method that’s wrongly implemented, here’s how it looks:

    void ICellEditor.SetControlValue(object value, IFormatProvider customFormatProvider)
    {
    this.SelectedItem = (ComboBoxItem)Convert.ChangeType(value, typeof(ComboBoxItem), customFormatProvider);
    }

    When I try to edit the cell this editor is in, it lags for a moment and I see the WinXP-style border of the control, but then it disappears and only white is shown in the cell. No button or drop down or anything. I had a similar issue before with my implementation of a custom WinDatePicker, in that case I had implemented SetControlValue wrong and fixing it fixed the issue. It works perfectly now. This is why I figured it might be the same problem with this control.

    Any clues?

    Imported from legacy forums. Posted by macke (had 2115 views)

    User (Old forums)
    Member
    Post count: 23064

    This forum is cool, I often find the answer to my problem right after I post ;o)
    I seem to have misunderstood how you implement the interfaces. Obviously you have to make the get/set methods return/set the same type that is defined by the cell.

    Here’s my new implementation that works fine:
    void ICellEditor.SetControlValue(object value, IFormatProvider customFormatProvider)
    {
    for (int i = 0; i < this.Items.Count; i++)
    {
    if (this.Items[i].Values[0].ToString() == (string)Convert.ChangeType(value, typeof(string), customFormatProvider))
    {
    this.SelectedItem = this.Items[i];
    return;
    }
    }
    }

    Imported from legacy forums. Posted by macke (had 2862 views)

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