示例#1
0
 private void DisciplinesSort_CheckedChanged(object sender, EventArgs e)
 {
     if (DisciplinesSort.Checked)
     {
         MaterialsGridView.Sort(MaterialsGridView.Columns[1], ListSortDirection.Ascending);
     }
 }
示例#2
0
        private void SelectMaterials(string text)
        {
            int g_width  = 0;
            int g_height = 0;

            if (text == MaterialsHintText)
            {
                text = String.Empty;
            }
            MySqlDataAdapter adap  = new MySqlDataAdapter();
            DataTable        table = new DataTable();

            using (MySqlConnection con = DBUtils.GetDBConnection())
            {
                con.Open();
                MySqlCommand cmd = new MySqlCommand("ShowMaterials", con)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("_name", text);
                adap.SelectCommand = cmd;
                adap.Fill(table);
                MaterialsGridView.DataSource = table;
                MaterialsGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                MaterialsGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            }
            foreach (DataGridViewColumn column in MaterialsGridView.Columns)
            {
                if (column.Visible == true)
                {
                    g_width += column.Width;
                }
            }
            Width = g_width + 75;
            if (UserSort.Checked)
            {
                MaterialsGridView.Sort(MaterialsGridView.Columns[0], ListSortDirection.Ascending);
            }
        }