PROGRAM TO DEMONSTRATE COMBOBOX


10.      PROGRAM TO DEMONSTRATE COMBOBOX

 PROGRAM TO DEMONSTRATE COMBOBOX
Step 1:-Select a NEW file.
Step 2:-Select a project tab from the new window and from that select MFC application wizard [exe] option and give a project name as combo box and click ok.
Step 3:-
Þ    MFC Application wizard window is appeared.
Þ    Select dialog based document settings in step 1, click next.
Þ    Select default settings from step 2 to step 6 and click finish.
Þ    New projects information on window will appear and click ok.
Step 4:-Now place the following controls on the dialog editor two static boxes, one edit box, and one combo box.

Step 5:-Goto-> view-> class wizard-> select IDC_COMBO1-> add variables -> m_combo and category as control -> and another variable as m_text for edit box.
Step 6:-Goto -> class view -> select OnInitDialog() method -> add the following code.
                                    BOOL CCombo1Dlg::OnInitDialog()
                                    {
                                                CDialog::OnInitDialog();
                                                m_combo.AddString(“Item 1”);
                                                m_combo.AddString(“Item 2”);
                                                m_combo.AddString(“Item 3”);
                                                m_combo.AddString(“Item 4”);
                                    }
Step 7:-Goto -> view -> class wizard -> message maps -> IDC_COMBO1 -> CBN_SELCHANGE -> OnSelChange Combo() method -> ok.
Step 8:-Goto -> class view -> CComboDlg -> OnSelChange Combo() -> add the following code:
                                    void CComboboxDlg::OnSelChangeCombo1()
                                    {
                                                m_combo.GetLBText(m_combo.GetCursel(), m_text);
                                                UpdateData(false);
                                    }
Step 9:-Build…………Compile………..Execute.


No comments:

Post a Comment