示例#1
0
 private void LoginSort_CheckedChanged(object sender, EventArgs e)
 {
     if (LoginSort.Checked)
     {
         UsersInfoGridView.Sort(UsersInfoGridView.Columns[0], ListSortDirection.Ascending);
     }
 }
示例#2
0
        private void SelectUsers(string text)
        {
            MySqlDataAdapter adap = new MySqlDataAdapter();
            int g_width           = 0;

            if (text == UserHintText)
            {
                text = String.Empty;
            }
            try
            {
                using (MySqlConnection con = DBUtils.GetDBConnection())
                {
                    con.Open();
                    MySqlCommand cmd = new MySqlCommand("ShowUsers", con)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.AddWithValue("_name", text);
                    adap.SelectCommand = cmd;
                    DataTable table = new DataTable();
                    adap.Fill(table);
                    UsersInfoGridView.DataSource = table;
                    UsersInfoGridView.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    foreach (DataGridViewColumn column in UsersInfoGridView.Columns)
                    {
                        if (column.Visible == true)
                        {
                            g_width += column.Width;
                        }
                    }
                    Width = g_width + 90;
                }
                if (FioSort.Checked)
                {
                    UsersInfoGridView.Sort(UsersInfoGridView.Columns[3], ListSortDirection.Ascending);
                }
            }
            catch (Exception e)
            {
                MyMessages.ErrorMessage(e.Message);
            }
        }