コード例 #1
0
        /// <summary>
        /// 双击修改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvStuinfo_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            //赋值
            Stuinfo s = new Stuinfo();

            s.SNO     = dgvStuinfo.SelectedRows[0].Cells["SNO"].Value.ToString();
            s.Pwd     = dgvStuinfo.SelectedRows[0].Cells["Pwd"].Value.ToString();
            s.StuName = dgvStuinfo.SelectedRows[0].Cells["StuName"].Value.ToString();
            s.Sex     = dgvStuinfo.SelectedRows[0].Cells["Sex"].Value.ToString();

            s.Age     = dgvStuinfo.SelectedRows[0].Cells["Age"].Value == DBNull.Value ? 0 : Convert.ToInt32(dgvStuinfo.SelectedRows[0].Cells["Age"].Value);
            s.Address = dgvStuinfo.SelectedRows[0].Cells["Address"].Value == DBNull.Value ? "" : dgvStuinfo.SelectedRows[0].Cells["Address"].Value.ToString();

            frmStuEdit stu = new frmStuEdit(s);

            stu.Show();
        }
コード例 #2
0
        /// <summary>
        /// 录入按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmStuEdit stu = new frmStuEdit(null);

            stu.Show();
        }