public static void Completed(QueryHelperClass qhc, List<StatHelperClass> shc, DataGridView dataGridView1, EventHandler eh)
        {
            for (int j = 0; j < shc.Count; j++)
            {
                if (shc[j].count > 0)
                {
                    dataGridView1.Rows.Clear();
                    dataGridView1.Columns.Clear();
                    int colIndex = EnsureColumnsInDataGrid(shc[j], dataGridView1);

                    dataGridView1.Columns[colIndex].ContextMenuStrip = new ContextMenuStrip();
                    dataGridView1.Columns[colIndex].ContextMenuStrip.Tag = new object[] { shc[j], colIndex };

                    if (shc[j].useArealUnit)
                    {
                        dataGridView1.Columns[colIndex].ContextMenuStrip.Items.Add(new ToolStripLabel("Acres", null, false, new EventHandler(eh)));
                        dataGridView1.Columns[colIndex].ContextMenuStrip.Items.Add(new ToolStripLabel("Square Feet", null, false, new EventHandler(eh)));
                        dataGridView1.Columns[colIndex].ContextMenuStrip.Items.Add(new ToolStripLabel("Square Miles", null, false, new EventHandler(eh)));
                        dataGridView1.Columns[colIndex].ContextMenuStrip.Items.Add(new ToolStripSeparator());
                        dataGridView1.Columns[colIndex].ContextMenuStrip.Items.Add(new ToolStripLabel("Hectares", null, false, new EventHandler(eh)));
                        dataGridView1.Columns[colIndex].ContextMenuStrip.Items.Add(new ToolStripLabel("Square Meters", null, false, new EventHandler(eh)));
                    }
                    else
                    {
                        dataGridView1.Columns[colIndex].ContextMenuStrip.Items.Add(new ToolStripLabel("Feet", null, false, new EventHandler(eh)));
                        dataGridView1.Columns[colIndex].ContextMenuStrip.Items.Add(new ToolStripLabel("Meters", null, false, new EventHandler(eh)));
                    }

                    if (dataGridView1.Rows.Count >= 7)
                    {
                        //dataGridView1.Rows[0].Cells[colIndex].Value = shc[j].CoordinateSystem;
                        dataGridView1.Rows[0].Cells[colIndex].Value = shc[j].LinearUnit;
                        dataGridView1.Rows[1].Cells[colIndex].Value = shc[j].count;
                        dataGridView1.Rows[2].Cells[colIndex].Value = shc[j].sum;
                        dataGridView1.Rows[3].Cells[colIndex].Value = shc[j].min;
                        dataGridView1.Rows[4].Cells[colIndex].Value = shc[j].max;
                        dataGridView1.Rows[5].Cells[colIndex].Value = shc[j].mean;
                        //dataGridView1.Rows[7].Cells[colIndex].Value = shc[j].range;
                        dataGridView1.Rows[6].Cells[colIndex].Value = (qhc == null)? "" : qhc.LastQueryStrings.FirstOrDefault();
                    }
                    else
                    {
                        dataGridView1.Rows.Clear();
                        //dataGridView1.Rows.Add(new object[] { "Coordinate System", shc[j].CoordinateSystem }); //0
                        dataGridView1.Rows.Add(new object[] { "Units", shc[j].LinearUnit }); //1
                        dataGridView1.Rows.Add(new object[] { "Number of Features", shc[j].count }); //2
                        dataGridView1.Rows.Add(new object[] { "Sum", shc[j].sum.ToString("N") }); //3
                        dataGridView1.Rows.Add(new object[] { "Min", shc[j].min.ToString("N") }); //4
                        dataGridView1.Rows.Add(new object[] { "Max", shc[j].max.ToString("N") }); //5
                        dataGridView1.Rows.Add(new object[] { "Mean", shc[j].mean.ToString("N") });                                          //6
                        dataGridView1.Rows.Add(new object[] { "Query String", (qhc == null)? "" : qhc.LastQueryStrings.FirstOrDefault() });
                        //dataGridView1.Rows.Add(new object[] { "Range", shc[j].range.ToString("N") }); //7
                    }

                    DoConversion(dataGridView1, shc[j], "Acres", colIndex);
                }
            }
        }
        private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
        {
            try
            {
                selectedRadio = comboBox1.SelectedItem.ToString();

                string filename = selectedRadio;
                string fieldName = selectedRadio;

                listBox2.Items.Clear();

                if (bUseNwi) //NWI
                {
                    switch (selectedRadio)
                    {
                        case "Subsystem":
                            goto default;

                        case "Subclass":

                            qhc = new QueryHelperSubclass();
                            break;

                        case "Class":
                            fieldName = "Class1";
                            goto default;
                        case "Water Chemistry":
                            fieldName = "Chemistry1";
                            filename = "Chemistry";
                            goto default;
                        case "Water Regime":
                            fieldName = "Water1";
                            filename = "Water";
                            goto default;
                        case "Special Modifiers":
                            fieldName = "Special1";
                            filename = "Special";
                            goto default;

                        default:
                            qhc = new QueryHelperClass();
                            break;
                    };
                }
                else // NWI+
                {
                    switch (selectedRadio)
                    {
                        case "Landscape":
                            break;

                        case "Landform":
                            break;

                        case "Waterflow":
                            fieldName = "Water_flow";
                            break;

                        case "Waterbody":
                            break;

                        default:
                            filename = Regex.Replace(selectedRadio, "[\\(\\) ]", ""); //fieldName.Replace(" ", "");

                            if (filename.IndexOf("Waterbody") > -1)
                            {
                                filename += "Q";
                            }

                            fieldName = selectedRadio.Split(' ')[0];
                            break;

                        case "Surface Water Detention":
                            fieldName = "Surf_Water";
                            filename = "SWD";

                            break;

                        case "Coast Storm Surge Detention":
                            fieldName = "Coast_Stor";
                            filename = "CSSD";

                            break;

                        case "Streamflow Maintenance":
                            fieldName = "Stream_Mai";
                            filename = "SM";

                            break;

                        case "Nutrient Transformation":
                            fieldName = "Nutrnt_Tra";
                            filename = "NT";

                            break;

                        case "Carbon Sequestration":
                            fieldName = "Carbon_Seq";
                            filename = "CS";

                            break;

                        case "Sediment Particulate Retention":
                            fieldName = "Sed_Part_R";
                            filename = "SR";

                            break;

                        case "Bank / Shoreline Stabilization":
                            fieldName = "Bank_Shore";
                            filename = "BS";

                            break;

                        case "Provision of Fish/Aquatic Invertebrate Habitat":
                            fieldName = "Prov_Fish_";
                            filename = "ProvFish";

                            break;

                        case "Provision of Waterfowl and Waterbird Habitat":
                            fieldName = "Prov_WFowl";
                            filename = "ProvBird";

                            break;

                        case "Provision of Other Wildlife Habitat":
                            fieldName = "Prov_Other";
                            filename = "ProvOtherWildHab";

                            break;

                        case "Provision of Unique/Uncommon/Highly Diverse Wetlant Plant Communities":
                            fieldName = "Prov_Hab_U";
                            filename = "ProvUWPC";

                            break;
                    }

                    filename = "NWIPlus" + filename;
                }

                listBox2.Items.AddRange(qhc.getQueryValueOptions(fieldName, filename));
            }
            catch (Exception ee)
            {
            }
        }