Override procedure of seting cell value to dataitem

Posted by: essentia on 8 September 2017, 1:32 pm EST

  • Posted 8 September 2017, 1:32 pm EST

    I need to override code witch set value to object in dataSource when cell value changed


    And that is why I am asking about this

    I have some business object with property of IList type, my custom CellType returns IList on GetEditorValue() but

    spread not set not set this value in to object (property setter not called)




  • Replied 8 September 2017, 1:32 pm EST


    If your project is zipped and less than 256KB, then when you post to the thread, there is an Options tab you can click on that has a place for attaching files. If the zip is larger than 256KB, or you do not want to post it, you can email it to me at fpsupport@fpoint.com.

  • Replied 8 September 2017, 1:32 pm EST


    The Parse method is the method to override in your custom celltype to take the value that will be written to the DataModel and change it to the object you want to pass into the DataModel. The object stored in the DataModel is the object written back to the bound DataSource.

  • Replied 8 September 2017, 1:32 pm EST

    No it doesn't work

    Parse not even calls in this circumstances.

    Parse acept string it's another scenario

    In my case when I am close editor (call ValueChanged in sub editor) in cell type spread calls GetEditorValue

    How I understand value that I return in GetEditorValue spred then set in to my DataItem.


     This property of my business object has type IList and spread do not set value in to it.

    I do some tests in find out that when I change type of property to List it starts to set value

    Is spread can't work with Interface properties?

    I realy need some event or somthing when i have current DataItem (my object) and cell where value changed or value provided by this cell

  • Replied 8 September 2017, 1:32 pm EST


    I am not sure what you are trying to do in your custom celltype. Could you post a small zipped project reproduicng the behavior you are seeing for us to debug?

  • Replied 8 September 2017, 1:32 pm EST

    This is simple project witch represents concept of my problem.

    MyClass is object witch I bind in to spread. It has two properties, one has OptionClass type and other IOptionClass type. There is two custom cell types to represent this properties CustomCellA and CustomCellB, they are almoste same but CustomCellA returns OptionClass type in GetEditorValue() to match PropA (of MyClass) type and CuctomCellB returns IOptionClass type in GetEditorValue() to match PropB type.

    Now the problem, all types in celltypes and properties are match but if you set the break points on settets of PropA and PropB of MyClass and select something in corresponding comboboxes on form you’l see that property with type OptionClass works wery well (spread sets selected value in too it), but property with “interface” type IOptionClass does not set at all.

    I think spread can’t work with “interface” property types, but I don’t understand why.

    Maybe i can somehow force spread to set “interface” properties

    or replace this logic and set values in to objects by myself after cell edit fnished. How I can do this?

  • Replied 8 September 2017, 1:32 pm EST


    In the project you sent, neither classes was correctly setting the value into the bound DataSource. I corrected CustomCellA in the code below. I do not know how to write this code with Interface calls since you can not instantiate a new Interface object like I am doing in this code.


    public class CustomCellA : ComboBoxCellType


    public CustomCellA()


    Items = new[] {"Opt 1", "Opt 2", "Opt 3"};

    Editable = true;

    EditorValue = EditorValue.String;


    public override object GetEditorValue()


    OptionClass _option = new OptionClass();

    _option.Name = (string) base.GetEditorValue();

    return _option;


    public override System.Windows.Forms.Control GetEditorControl(FarPoint.Win.Spread.Appearance appearance, float zoomFactor)


    combo = (FarPoint.Win.FpCombo)base.GetEditorControl(appearance,zoomFactor);

    return combo;



    public override void SetEditorValue(object value)


    if (value != null)

    combo.SelectedText = ((OptionClass)value).Name;


    public override string Format(object obj)


    string ret;

    if (obj == null)

    ret = string.Empty;

    ret = ((OptionClass)obj).Name;

    return base.Format(ret);



    private FarPoint.Win.FpCombo combo;


  • Replied 8 September 2017, 1:32 pm EST



    Seems you do not understand me.

    CustomCellA works just perfect.

    The problem was with CustomCellB even not with CellType itself but with whole spread

    It can not set value in to object that I bound when corresponding property declared with Interface type (not certain type but interface)!

    Cell type returns object that implements this interface (and it already created by Cell type) and i don't understand what the problem to set already created object of correct type in to property with interface type.



    You have object with property declared as IList (public IList SomeProperty )

    In the cell type you create and return List which implements IList !

    Spread should set this object of correct type in to property (SomeProperty) but it's not gonna happens.

    If you replace declaration of property in to certain type (not interface)  (public List SomeProperty ), it's work just perfect



  • Replied 8 September 2017, 1:32 pm EST


    Looking at your code for CustomCellB again, I now see how to create a new instance of the Interface object. Debugging into this it looks like when we are writing the value back to the bound DataSource, we are checking for a particular object type and not if it is an interface and that the object type implements that interface. I have reported this as a bug (#23236) for the development team to fix for the next maintenance release.

     Also, I am not sure how you have the first column working correctly. It is not working in my tests, nor do I expect it to. When I select an item from the combobox and press enter, the value shows in the cell. But, when I click on another cell to open that combobox, the value in the first cell disappears. With the changes I pisted to the code, everything works as expected for me in the first column.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels