开发者

Remember the last selected item of a combobox

开发者 https://www.devze.com 2023-03-25 08:02 出处:网络
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 t

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

精彩评论

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