Combo Box, SetCurSel ( 0 )
-
Hi, I created a dialog with a combo box. I entered a few items ("A;B;C;D") to the combox box's property->data field. I know I need to call SetCurSel ( ) function to sets the combo box's current selection by a data index. Otherwise, the combo box appers empty until I drop the list down. I also read something about fixing the problem in OnInitDialog ( ). But I could not find out how they come together. I think my question is where is "OnInitDialog". Should I derive a new class from that combo box? If that is the case, how my dialog display the same combo box again? Any suggestions would be appreciated? Thanks, Kevin
-
Hi, I created a dialog with a combo box. I entered a few items ("A;B;C;D") to the combox box's property->data field. I know I need to call SetCurSel ( ) function to sets the combo box's current selection by a data index. Otherwise, the combo box appers empty until I drop the list down. I also read something about fixing the problem in OnInitDialog ( ). But I could not find out how they come together. I think my question is where is "OnInitDialog". Should I derive a new class from that combo box? If that is the case, how my dialog display the same combo box again? Any suggestions would be appreciated? Thanks, Kevin
OnInitDialog is called by the framework before the dialog is displayed. It's an ideal place to do the sort of thing you want to do (fill combo boxes, set text in text boxes etc). It's a member function of CDialog, so (assuming you're using MFC), you'll need to override this function and put your code in there. Note that although you are ultimately handling a WM_INITDIALOG message, in this case you don't need an entry in the message map, just an override of the base class function.
-
Hi, I created a dialog with a combo box. I entered a few items ("A;B;C;D") to the combox box's property->data field. I know I need to call SetCurSel ( ) function to sets the combo box's current selection by a data index. Otherwise, the combo box appers empty until I drop the list down. I also read something about fixing the problem in OnInitDialog ( ). But I could not find out how they come together. I think my question is where is "OnInitDialog". Should I derive a new class from that combo box? If that is the case, how my dialog display the same combo box again? Any suggestions would be appreciated? Thanks, Kevin
Hi- go to class wizard and select the dialog box class on which your combo box is in, then from create an event handler(also from class wizard) for the WM_INITDIALOG message or the OnInitDialog() function, place your code to initialize (select the item you want in a combo box), the code in this function will be executed when your dialog box is initialized, and before it is visible on the screen. Regrds, Mohammad Gdeisat And ever has it been that love knows not its own depth until the hour of separation
-
Hi- go to class wizard and select the dialog box class on which your combo box is in, then from create an event handler(also from class wizard) for the WM_INITDIALOG message or the OnInitDialog() function, place your code to initialize (select the item you want in a combo box), the code in this function will be executed when your dialog box is initialized, and before it is visible on the screen. Regrds, Mohammad Gdeisat And ever has it been that love knows not its own depth until the hour of separation
Great, it works. One more question. I have about 15 data (a;b;c;d;e;...) with my combo box. When I clicked the combo box, it only showed one entry at a time when I hit the up or down arrow. How can I show multiple rows to be selected? Thanks, Kevin
-
Great, it works. One more question. I have about 15 data (a;b;c;d;e;...) with my combo box. When I clicked the combo box, it only showed one entry at a time when I hit the up or down arrow. How can I show multiple rows to be selected? Thanks, Kevin
kevincwong wrote:
How can I show multiple rows
If you want the combo box to display more than on item when clicked, try this In design mode, Right click on the drop down box, Use the selection box to resize the height.
DEBUGGING : Removing the needles from the haystack.
-
kevincwong wrote:
How can I show multiple rows
If you want the combo box to display more than on item when clicked, try this In design mode, Right click on the drop down box, Use the selection box to resize the height.
DEBUGGING : Removing the needles from the haystack.
I got it. It works. Thank you so much! Kevin
-
I got it. It works. Thank you so much! Kevin