Пример #1
0
        /// <summary>
        /// 数据表名称标题发生改变时触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Lbl_dbname_TextChanged(object sender, EventArgs e)
        {
            //获得数据表名称
            string shtname = lbl_dbname.Text;

            Setting._currentdb = shtname;
            //获得该表下数据datatable
            string str_sql = $"select * from {shtname}";

            mycontroller.SelectDB("default");
            DataTable mydt = mycontroller.GetDataFromTable(str_sql);

            lbl_shuliang.Text = $"({mydt.Rows.Count} 条)";
            //将数据绑定到dgv_data
            CommonMethod.AddXuhao(mydt);
            dgv_data.DataSource = null;
            dgv_data.DataSource = mydt;
        }