private void button2_Click(object sender, EventArgs e)
        {
            //edit selected questionnaire

            //do we have a questionnaire open already ?
            if (qFormIsOpen)
            {
                //still open
                errorBox.setLabel("Error: You have a Questionnaire already open: you must close it first.");
                errorBox.ShowDialog();
                return;

            }

            Participant selectedPart = (Participant)listBox2.SelectedItem;

            if (selectedPart == null)
            {

                errorBox.setLabel("Error: Please select a Participant from the list");
                errorBox.ShowDialog();
                return;

            }

            //is the Part locked
            if (selectedPart.Locked)
            {
                errorBox.setLabel("Error: Cannot edit a locked Participant");
                errorBox.ShowDialog();
                return;

            }

            if (dataDir == null)
            {
                errorBox.setLabel("Error: Please set the data directory (settings)");
                errorBox.ShowDialog();
                return;

            }

            //open the form

            //has the user selected a language and participant ID

            string language = selectedPart.getLanguage();

            string xmlFilePath;

            //what is the filePath for the xml config file
            if (language == "English")
            {

                xmlFilePath = dataDir + "\\EQuestionnaire_English.xml";

            }
            else if (language == "Chewa")
            {

                xmlFilePath = dataDir + "\\EQuestionnaire_Chewa.xml";

            }
            else
            {

                //language not supported
                errorBox.setLabel("Error: Language '" + language + " is not currently supported");
                errorBox.ShowDialog();
                return;

            }

            //check that the xml file exists
            if (!File.Exists(xmlFilePath))
            {

                errorBox.setLabel("Error: Cannot find expected configuration file:" + xmlFilePath);
                errorBox.ShowDialog();
                return;

            }

            //participantID
            string partID = selectedPart.getID();

            //has the user set the GPS baud rate, port and the main data dir ?

            portNum = (string)comboBox1.SelectedItem;
            baudRate = (string)comboBox2.SelectedItem;
            gpsCountry = (string)comboBox3.SelectedItem;

            if (portNum == null && Utils.GPSenabled)
            {

                errorBox.setLabel("Error: Please set the GPS port Number (settings)");
                errorBox.ShowDialog();
                return;

            }

            if (baudRate == null && Utils.GPSenabled)
            {

                errorBox.setLabel("Error: Please set the GPS baudrate (settings)");
                errorBox.ShowDialog();
                return;

            }

            if (gpsCountry == null && Utils.GPSenabled)
            {
                errorBox.setLabel("Error: Please set the GPS country (settings)");
                errorBox.ShowDialog();
                return;

            }

            //check that this participant does not already exist, i.e. that the new datadir does not exist

            string partDataDir = selectedPart.getPath();

            //turn off the GPS logger if on
            /*
            if (loggerStatus == "on")
            {

                //turn off until user exits the Q window
                //disable the timer
                timer1.Enabled = false;

                //close the serial port
                if (serialPort1.IsOpen)
                {
                    serialPort1.Close();

                }

                label11.Text = "suspended while Questionnaire is open";
                label12.Text = "suspended while Questionnaire is open";

                loggerStatus = "suspended";

            }
             * */

            //open the form
            currentSurvey = new Form1();

            try
            {

                //start the survey
                currentSurvey.startSurvey(xmlFilePath, partDataDir, partID, false, portNum, baudRate, this, gpsCountry);

                currentSurvey.Show();

                qFormIsOpen = true;

                openParticipantID = partID;

            }
            catch(ObjectDisposedException e2){

                //something went wrong with startup, e.g. XML parsing exception

                qFormIsOpen = false;

            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //new questionnaire

            //do we have a questionnaire open already ?
            if (qFormIsOpen)
            {
                //still open
                errorBox.setLabel("Error: You have a Questionnaire already open: you must close it first.");
                errorBox.ShowDialog();
                return;

            }

            //has the user selected a language and participant ID

            string language = (string)listBox1.SelectedItem;

            if (language == null)
            {
                errorBox.setLabel("Error: Please select language");
                errorBox.ShowDialog();
                return;

            }

            string xmlFilePath;

            //what is the filePath for the xml config file
            if(language == "English"){

                xmlFilePath= dataDir + "\\EQuestionnaire_English.xml";

            }

            else if (language == "Chewa")
            {

                xmlFilePath = dataDir + "\\EQuestionnaire_Chewa.xml";

            }

            else
            {

                //language not supported
                errorBox.setLabel("Error: Language '" + language + " is not currently supported");
                errorBox.ShowDialog();
                return;

            }

            //check that the xml file exists
            if(! File.Exists(xmlFilePath)){

                errorBox.setLabel("Error: Cannot find expected configuration file:" + xmlFilePath);
                errorBox.ShowDialog();
                return;

            }

            //participantID
            string partID = textBox1.Text;

            if (string.IsNullOrWhiteSpace(partID))
            {

                errorBox.setLabel("Error: Please enter a Participant ID");
                errorBox.ShowDialog();
                return;

            }

            //check that the partID does not contain any underscore characters (which will cause problems as its gets embedded into dir/file names which use underscores as separators
            if (partID.Contains("_"))
            {

                errorBox.setLabel("Error: The Participant ID contains underscore character(s), which is not allowed.");
                errorBox.ShowDialog();
                return;

            }

            //does this participant already exist (in which case they should be using the existing participant page)?
            foreach (Participant part in listBox2.Items)
            {
                if (partID == part.getID())
                {

                    errorBox.setLabel("Error: This participant already exists");
                    errorBox.ShowDialog();
                    return;

                }

            }

            //has the user set the GPS baud rate, port and the main data dir ?

            portNum = (string)comboBox1.SelectedItem;
            baudRate = (string)comboBox2.SelectedItem;
            gpsCountry = (string)comboBox3.SelectedItem;

            if (dataDir == null)
            {
                errorBox.setLabel("Error: Please set the data directory (settings)");
                errorBox.ShowDialog();
                return;

            }

            if (portNum == null && Utils.GPSenabled)
            {

                errorBox.setLabel("Error: Please set the GPS port Number (settings)");
                errorBox.ShowDialog();
                return;

            }

            if (baudRate == null && Utils.GPSenabled)
            {

                errorBox.setLabel("Error: Please set the GPS baudrate (settings)");
                errorBox.ShowDialog();
                return;

            }

            if (gpsCountry == null && Utils.GPSenabled)
            {
                errorBox.setLabel("Error: Please set the GPS country (settings)");
                errorBox.ShowDialog();
                return;

            }

            //check that this participant does not already exist, i.e. that the new datadir does not exist

            string partDataDir = dataDir + "\\participant_data_" + language + "_" + partID;

            if (Directory.Exists(partDataDir))
            {
                //user already exists
                errorBox.setLabel("Error: This Participant already exists.");
                errorBox.ShowDialog();
                return;

            }

            //create the new dir.
            try
            {

                Directory.CreateDirectory(partDataDir);

            }
            catch
            {

                errorBox.setLabel("Error: Could not create directory for this participant. You may not have permission to write to this location");
                errorBox.ShowDialog();
                return;

            }

            //if the logger is running: suspend it
            //i.e. disconnect from the serial port
            /*
            if (loggerStatus == "on")
            {

                //turn off until user exits the Q window
                //disable the timer
                timer1.Enabled = false;

                //close the serial port
                if (serialPort1.IsOpen)
                {
                    serialPort1.Close();

                }

                label11.Text = "suspended while Questionnaire is open";
                label12.Text = "suspended while Questionnaire is open";

                loggerStatus = "suspended";

            }
             * */

            //open the form
            currentSurvey = new Form1();

            try
            {

                //start the survey
                currentSurvey.startSurvey(xmlFilePath, partDataDir, partID, true, portNum, baudRate, this, gpsCountry);

                currentSurvey.Show();

                qFormIsOpen = true;

                openParticipantID = partID;

            }
            catch (ObjectDisposedException e2)
            {

                //something went wrong with startup, e.g. XML parsing exception

                qFormIsOpen = false;

            }
        }