title: I want to assign integer values to each combo box selection and to collectively print them in a text file
body: <p>I am making a kind of student database, in which, for every new student, his/her details are added and then there is a combo box to choose the subject, and an adjacent edit control to enter the respective marks. I want to assign the marks simultaneously without pressing any button. How can this be achieved ??</p>
  
  <p>The code-</p>
  
  <pre><code>void CFile03Dlg::OnSelchangeCombo()
  {
      // TODO: Add your control notification handler code here
  
  
          int n= m_SSubject.GetCurSel();
          arr[n]=m_SMarks;
  
  
  }
  
  
  
  
  void CFile03Dlg::OnBnClickedButton1()
  {
      // TODO: Add your control notification handler code here
      UpdateData(TRUE);
      int h=0;
      CStdioFile file_object(L"D:\\Docs\\Student.txt",CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate);
  
  
      CString fc1=m_SName, fc2=m_SClass, fc3=m_SRoll, fc4;
      file_object.SeekToEnd();
  
      for(h=0;h&lt;3;h++)
      {
      fc4.Format(L"%d", arr[h]);
      }
  
       file_object.WriteString(L"Name: ");
       file_object.WriteString(fc1);
       file_object.WriteString(L"\n");
  
       file_object.WriteString(L"Class: ");
       file_object.WriteString(fc2);
       file_object.WriteString(L"\n");
  
       file_object.WriteString(L"Roll No.: ");
       file_object.WriteString(fc3);
       file_object.WriteString(L"\n");
  
      // file_object.WriteString(L"Name:");
        CString selection;
  
        for(h=0;h&lt;3;h++)
        {
  
  
               if(h==0)
                  {
                      m_SSubject.GetLBText(h, selection);
                      file_object.WriteString(selection);
                      file_object.WriteString(L"  Marks: ");
                      file_object.WriteString(fc4);
  
               }
  
               else if(h==1)
              {
                      m_SSubject.GetLBText(h, selection);
                  file_object.WriteString(selection);
  
                  file_object.WriteString(L"  Marks: ");
                      file_object.WriteString(fc4);
              }
  
               else if(h==2)
              {
                      m_SSubject.GetLBText(h, selection);
                  file_object.WriteString(selection);
  
                  file_object.WriteString(L"  Marks: ");
                      file_object.WriteString(fc4);
              }
               else if(h==3)
              {
                      m_SSubject.GetLBText(h, selection);
                  file_object.WriteString(selection);
  
                  file_object.WriteString(L"  Marks: ");
                      file_object.WriteString(fc4);
              }
  
              file_object.WriteString(L"\n");
  
        }  
      file_object.WriteString(L"\n");
      UpdateData(FALSE);
  
  }
  </code></pre>