//查询系统用户 private void queryUser() { //查询所有用户信息 DataTable dd = us.listUser(); dd.Columns.Add("类别", typeof(string)); foreach (DataRow rows in dd.Rows) { if (rows[0].ToString() == "admin") { rows["类别"] = "管理员"; } else { rows["类别"] = "普通用户"; } rows[1] = "******"; } this.dataGridView1.DataSource = dd; this.dataGridView1.Columns[0].HeaderCell.Value = "用户名称(登录用)"; this.dataGridView1.Columns[1].HeaderCell.Value = "密码"; this.dataGridView1.Columns[2].HeaderCell.Value = "用户名称"; this.dataGridView1.Columns[3].HeaderCell.Value = "性别"; this.dataGridView1.Columns[4].HeaderCell.Value = "出生年月"; this.dataGridView1.Columns[5].HeaderCell.Value = "类别"; //this.dataGridView1.Columns[1].Width = 110; //this.dataGridView1.Columns[4].Width = 130; this.dataGridView1.RowsDefaultCellStyle.ForeColor = Color.Black; this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; }
private void frmLogin_Load_1(object sender, EventArgs e) { this.label3.Text = "中科弘卫一体化查体系统";//标题 this.label3.ForeColor = Color.Blue; label3.Font = new Font("微软雅黑", 15F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(134))); label3.BringToFront(); this.label4.Text = "24小时服务电话:4008150101"; //标题 string str = Application.StartupPath; //项目路径 this.button1.BackgroundImage = Image.FromFile(@str + "/images/login1.png"); this.button2.BackgroundImage = Image.FromFile(@str + "/images/tuichu.png"); this.pictureBox1.Image = Image.FromFile(@str + "/images/logo.png"); DataTable dd = us.listUser(); this.comboBox1.DataSource = dd; //绑定数据源 this.comboBox1.DisplayMember = "username"; //显示给用户的数据集表项 this.comboBox1.ValueMember = "username"; //操作时获取的值 }