Combo Box Questions.
-
Hello All, I have a Combo Box IDC_COMBO, & in the Combo Box Properties (data) , I have added 1,2,3 --- till 10 numbers. And in the code I have used below code to set the default Combo box value to 0.
case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break;
Now the problem is its not showing the default value 0 on the dialog load and also combo box is empty ..its has no data ……its not showing numbers 1,2, ---10... Can anyone please help me & tell what is wrong ??? in the above code. Thanking you, Suresh HC. Edit/Delete MessageIn the property window of combobox you insert 1,2,3 or 1;2;3;
WhiteSky
-
In the property window of combobox you insert 1,2,3 or 1;2;3;
WhiteSky
-
Hello WhiteSky, Thanks for the responce, i did that added again 1,2,3,4 but still its not diaplying them , combo box has no data its empty. can u please tell what is wrong here????
You must use of ; not ,
WhiteSky
-
You must use of ; not ,
WhiteSky
-
Hello All, I have a Combo Box IDC_COMBO, & in the Combo Box Properties (data) , I have added 1,2,3 --- till 10 numbers. And in the code I have used below code to set the default Combo box value to 0.
case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break;
Now the problem is its not showing the default value 0 on the dialog load and also combo box is empty ..its has no data ……its not showing numbers 1,2, ---10... Can anyone please help me & tell what is wrong ??? in the above code. Thanking you, Suresh HC. Edit/Delete MessageSuresh H wrote:
And in the code I have used below code to set the default Combo box value to 0. case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break;
You are using wrong message for setting value.
CB_SETITEMDATA
is used to set item data for particular index. I'm not clear about your wording, I'm assuming that you want first value to be selected and default selection. You do this by using,HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO);
SendMessage(hwndCombo,CB_CB_SETCURSEL,0,0);Prasad Notifier using ATL | Operator new[],delete[][^]
-
No its not working I tried with both , and also ; . actually I am working on win32 api and not MFC.
If you use of
CB_ADDSTRING
for insert data to combobox instead property window what happens?
WhiteSky
-
Suresh H wrote:
And in the code I have used below code to set the default Combo box value to 0. case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break;
You are using wrong message for setting value.
CB_SETITEMDATA
is used to set item data for particular index. I'm not clear about your wording, I'm assuming that you want first value to be selected and default selection. You do this by using,HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO);
SendMessage(hwndCombo,CB_CB_SETCURSEL,0,0);Prasad Notifier using ATL | Operator new[],delete[][^]
Hello Prasad, Thanks for the responce.
HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETCURSEL,0,0);
Actually I have added numbers from 0– 10 in the Combo box properties under data. After the dialog load combo box is empty no values in that . can u plz tell me what is wrong ??? Yes I want the default value to be selected to 0. -
If you use of
CB_ADDSTRING
for insert data to combobox instead property window what happens?
WhiteSky
-
Hello All, I have a Combo Box IDC_COMBO, & in the Combo Box Properties (data) , I have added 1,2,3 --- till 10 numbers. And in the code I have used below code to set the default Combo box value to 0.
case WM_INITDIALOG: { HWND hwndCombo = GetDlgItem(hwnd, IDC_COMBO); SendMessage(hwndCombo,CB_SETITEMDATA,0,0); } break;
Now the problem is its not showing the default value 0 on the dialog load and also combo box is empty ..its has no data ……its not showing numbers 1,2, ---10... Can anyone please help me & tell what is wrong ??? in the above code. Thanking you, Suresh HC. Edit/Delete MessageThat properties page where you enter the initial data for the combo box only works in MFC apps.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ");
-
That properties page where you enter the initial data for the combo box only works in MFC apps.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ");