开发者

Remember the last selected item of a combobox

I have a dialog in a MFC project that contains a combobox with the following items: blue, black, yellow. When I start the dialog the combobox has the blue item selected. If I change to yellow, close the dialog and open the dialog again, I want the selected item to be yellow and not blue. 开发者_JAVA百科

Any idee how can I remember the last selected item ?


You can save it to registry. Check the codeproject article: History Combobox

If you don't want to retain the selected item after the application is restarted, a static member will do.


In your dialog class, have a static member and always set it to the last color used in the combo box. Since the member is static, it will persist even if you change the actual dialog object

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜