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:

    <FONT size=2><FONT size=2>

    ((</FONT><FONT color=#2b91af size=2>ComboBoxCellType</FONT><FONT size=2>)m_CBCell.CellType).EditorValue = </FONT><FONT color=#2b91af size=2>EditorValue</FONT><FONT size=2>.ItemData;</FONT>

    <FONT color=#0000ff size=2>string</FONT><FONT size=2> newValue = (</FONT><FONT color=#0000ff size=2>string</FONT><FONT size=2>)m_CBCell.Value; </FONT><FONT color=#008000 size=2>// this gets the desired string from ItemData

    </FONT><FONT size=2>

    m_CBCell.CellType = </FONT><FONT color=#0000ff size=2>null</FONT><FONT size=2>; </FONT><FONT color=#008000 size=2>// this sets m_CBCell.Text to "" & m_CBCell.Value to null

    </FONT><FONT size=2>

    </FONT><FONT color=#008000 size=2>// neither of the following changes m_CBCell.Text from "" or m_CBCell.Value from null

    </FONT><FONT size=2>

    m_CBCell.Text = newValue;

    m_CBCell.Value = newValue;

    </FONT></FONT><FONT size=2></FONT>
  • 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