Click here to Skip to main content
16,022,402 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am developing multiple choice quiz application in windows form. The quiz consists of 10 questions which are stored in database. The application has some sound functionality that reads out the question text when a button is clicked. A question together with its options are loaded on the same form when submit button is clicked. When the form is loaded for the first time the question text can read when sound button is clicked, so how do I make the same button to make different sounds at every form load depending on the displayed question text. I have the wave files for each question in my solution explorer. I don’t want to make ten buttons for every question. Thank you for your help.
Posted
Comments
George Jonsson 11-Sep-14 10:57am    
Not really clear what you want to do.
How many sounds do you have per question?
Sergey Alexandrovich Kryukov 11-Sep-14 10:59am    
First of all, even though there is the event Load, there is no such operation as form "loading". The form instance is created and later shown. You have plenty of other events to be used for your sound.
What have you tried so far? Any problems?
—SA
MariwanIT 11-Sep-14 16:39pm    
play sound in c# is simple but can you rephrase you question to better understand.
System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\mywavfile.wav");
player.Play();

add the code to the button but change player from 0 to n with soundfile according to the number
of your wav files.

then for each each question you can create a int variable
such as
int a = 0;
if(a==0)
{
sound 0 should play
}
if(a==1)
{
sound 1 should play
}
........
n

I think you can get benefits from my explanation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900