示例#1
0
        private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            Point mp = Control.MousePosition;

            List <string> options = new List <string>();

            foreach (DataRow datarow in m_dtCSV.Rows)
            {
                string celldata = datarow.ItemArray[0].ToString().Trim();
                if (!options.Contains(celldata))
                {
                    options.Add(celldata);
                }
            }

            ArdupilotMega.Controls.OptionForm opt = new ArdupilotMega.Controls.OptionForm();

            opt.StartPosition = FormStartPosition.Manual;
            opt.Location      = mp;

            opt.Combobox.DataSource = options;
            opt.Button1.Text        = "Filter";
            opt.Button2.Text        = "Cancel";

            opt.ShowDialog(this);

            if (opt.SelectedItem != "")
            {
                (dataGridView1.DataSource as DataTable).DefaultView.RowFilter = "col0 like '" + opt.SelectedItem + "'";

                //numberRowHeader();
            }
            else
            {
                (dataGridView1.DataSource as DataTable).DefaultView.RowFilter = "";
                //dataGridView1.DataSource = m_dtCSV;
                numberRowHeader();
            }

            /*
             * dataGridView1.SuspendLayout();
             *
             * foreach (DataGridViewRow datarow in dataGridView1.Rows)
             * {
             *  string celldata = datarow.Cells[0].Value.ToString().Trim();
             *  if (celldata == opt.SelectedItem || opt.SelectedItem == "")
             *      datarow.Visible = true;
             *  else
             *  {
             *      try
             *      {
             *          datarow.Visible = false;
             *      }
             *      catch { }
             *  }
             * }
             *
             * dataGridView1.ResumeLayout();
             * */
        }
示例#2
0
        private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            Point mp = Control.MousePosition;

            List<string> options = new List<string>();

            foreach (DataRow datarow in m_dtCSV.Rows)
            {
                string celldata = datarow.ItemArray[1].ToString().Trim();
                if (!options.Contains(celldata))
                {
                    options.Add(celldata);
                }
            }

            ArdupilotMega.Controls.OptionForm opt = new ArdupilotMega.Controls.OptionForm();

            opt.StartPosition = FormStartPosition.Manual;
            opt.Location = mp;

            opt.Combobox.DataSource = options;
            opt.Button1.Text = "Filter";
            opt.Button2.Text = "Cancel";

            opt.ShowDialog(this);

            if (opt.SelectedItem != "")
            {
                (dataGridView1.DataSource as DataTable).DefaultView.RowFilter = "col0 like '" + opt.SelectedItem + "'";
            }
            else
            {
                (dataGridView1.DataSource as DataTable).DefaultView.RowFilter = "";
            }

            /*
            dataGridView1.SuspendLayout();

            foreach (DataGridViewRow datarow in dataGridView1.Rows)
            {
                string celldata = datarow.Cells[0].Value.ToString().Trim();
                if (celldata == opt.SelectedItem || opt.SelectedItem == "")
                    datarow.Visible = true;
                else
                {
                    try
                    {
                        datarow.Visible = false;
                    }
                    catch { }
                }
            }

            dataGridView1.ResumeLayout();
             * */
        }