VSTO Excel,保存组合框文本,打开工作簿时重置组合框?
我的 Excel VSTO 解决方案中有几个组合框。这些组合是窗口形式的组合。
问题是我希望当用户重新打开电子表格时重新填充组合中的选定值。目前,我知道这些值是与电子表格一起保存的,我知道由于在同一台计算机上进行开发和测试,我遇到了 ClickOnce 安装程序问题,我可以看到电子表格打开,安装程序去获取新的版本。在那段时间里,我看到了我想要的组合值。
但是,一旦安装了自定义并且电子表格初始化,组合将重置为默认文本值。我可以想出几种方法来解决这个问题,包括使用缓存数据...有谁知道是否有一种简单的方法可以防止组合在电子表格打开时重置?
I have several ComboBoxes in an Excel VSTO Solution. The combos are windows forms combos.
The issue is that I'd like selected value in the combo to be repopulated when the user reopens the spreadsheet. Currently, I know that the values are saved with the spreadsheet, I know this I've ran into ClickOnce installer problems due to developing and testing on the same machine, and I can see the spreadsheet open, and the installer go to get the new version. During that time, I see the combo values I want.
However, once the customization installs and the spreadsheet initializes, the combos reset to default text values. I can think of a few ways to get around this, involving using cached data... Does anyone know if there is a simple way to keep the combos from resetting when the spreadsheet opens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道这是否一定是最好的解决方案,但这就是我最终所做的。
我首先将我的组合嵌入到单元格中。
然后我创建了一个子程序来将组合文本的值写回到控件所在的单元格中。
最后一个例程将单元格值写回到组合中。
为了使其全部正常工作,我使用了 WorkBoook BeforeSave 事件和 WorkSheet.StartUp 事件。
首先
然后
如果其他人知道避免这种情况的更好方法,请告诉我:)
I don't know if this is necessarily the best solution, but this is what I ended up doing.
I first embedded my combos into cells.
Then I created a sub to write the value of the Combo Text, back into the cell that the control resided in.
Finally a routine that writes the Cell Value back to the Combo.
To make it all work, I use the WorkBoook BeforeSave Event, and the WorkSheet.StartUp Event.
First
Then
If someone else knows of a better way to avoid this, let me know:)