Solved

Please help me asap! Combo Box + List Control Error

Posted on 2003-10-30
1
181 Views
Last Modified: 2013-11-20
Program Layout:

Cedit = m_strFile   // Prints the path of the file which contains the album (mp3's)
ComboBox = m_ComboBands // A list of bands
List Control = m_MyAlbums // the name of the bands albums
Button1 = Browse
Button2 = Rename
Button3 = Stop

What this program does is... once a file is selected. You then select which band it is on the comb box and then the list control shows the current bands album names, after selecting one you press rename and it renames the mp3's in the selected file.

Since you have an idea of my program. I have been having problems with getting the selection of the combo box to the list control. After compileing my code, i select a 311 and it displays both 311 and Adema. Please help me!

Heres my code.....

void CMp3RenamerDlg::OnSelchangeCombo1()
{
     char nSelection = m_ComboBands.GetCurSel();

     if( nSelection != LB_ERR )
     {
          if( nSelection, "311" )
          {
                                            m_MyAlbums.DeleteAllItems();
                m_MyAlbums.InsertItem(0, _T( "Music" ));
                m_MyAlbums.SetItemText(0,1, "1993");
               m_MyAlbums.InsertItem(0, _T("Self Titled"));
               m_MyAlbums.SetItemText(0,1, _T("1996"));
                 m_MyAlbums.InsertItem(0, _T("Transistor"));
                m_MyAlbums.SetItemText(0,1, _T("1997"));
               m_MyAlbums.InsertItem(0, _T("Live"));
               m_MyAlbums.SetItemText(0,1, _T("1998"));
                m_MyAlbums.InsertItem(0, _T("Soundsystem"));
                m_MyAlbums.SetItemText(0,1, _T("1999"));
               m_MyAlbums.InsertItem(0, _T("Grassroots"));
               m_MyAlbums.SetItemText(0,1, _T("2000"));
                m_MyAlbums.InsertItem(0, _T("From Chaos"));
                m_MyAlbums.SetItemText(0,1, _T("2001"));
               m_MyAlbums.InsertItem(0, _T("Evolver"));
               m_MyAlbums.SetItemText(0,1, _T("2003"));
          }
          if( nSelection, "Adema" )
          {
                                              m_MyAlbums.DeleteAllItems();
               m_MyAlbums.InsertItem(0, _T("Self Titled"));
               m_MyAlbums.SetItemText(0,1, _T("2001"));    
          }
     }
}
0
Comment
Question by:khaotiksociety
1 Comment
 
LVL 8

Accepted Solution

by:
martynjpearson earned 50 total points
ID: 9656091
Your syntax is wrong in the two if statements where you check for "311" and "Adema"

What you need to do is get the text from the combo box for the selected item, and then compare that with the text strings, thus :

if (nSelection != CB_ERR) // Not LB_ERR, although the two are the same thing!
{
   CString strText;
   m_ComboBands.GetLBText(nSelection, strText);

   if (strText == "311")
   {
      // ...
   }
   else if (strText == "Adema")
   {
      // ...
   }
}

Hope this helps
Martyn
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 54
sumHeights2  challenge 7 102
Problem to open Excel file 15 128
"Black Box" Testing of Control System Software 2 48
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now