can't replace Text in former ComboBoxCellType cell that used ItemData

Posted by: rgreene on 8 September 2017, 1:25 pm EST

  • Posted 8 September 2017, 1:25 pm EST

    In a column bound to a string property (in Spread 3.0), I need to temporarily change a selected cell to a combobox, then replace the original contents of the cell with the string the user selects from the combobox. This was working fine when the combobox just contained the possible choices in its Items array -- in the EditingStopped handler, I'd just change the cell's CellType back to null.


    But now I'd like to have one set of string choices displayed in the combobox Items that differ from a corresponding set of possibilities to be placed in the bound cell.  I tried using the combobox's ItemData to hold that corresponding set (as in your example where Items = {"One", "Two", "Three"} and ItemData = {"1", "2", "3"}).  Then in the EditingStopped handler, I change the cell's EditorValue to ItemData, record the corresponding Value, change the cell's CellType back to null, and then try to assign the recorded value to the cell's Text or its Value.  In either case the cell's Text remains an empty string and its Value null.  What do I need to do to be able to assign a string to that cell again?


    Here's the code from the EditingStopped handler:


    ((ComboBoxCellType)m_CBCell.CellType).EditorValue = EditorValue.ItemData;


    string newValue = (string)m_CBCell.Value; // this gets the desired string from ItemData


    m_CBCell.CellType = null; // this sets m_CBCell.Text to "" & m_CBCell.Value to null


    // neither of the following changes m_CBCell.Text from "" or m_CBCell.Value from null


    m_CBCell.Text = newValue;


    m_CBCell.Value = newValue;

  • Replied 8 September 2017, 1:25 pm EST

    Please ignore previous post.  For some reason (something I changed elsewhere?) this is now working.  I still don't see the desired Text when stepping though in the debugger, but it does show up in the spreadsheet itself, perhaps because it's bound data?
Need extra support?

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

Learn More

Forum Channels