private void ListFnameForm_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'tbl_userDataSet1.std' table. You can move, or remove it, as needed. this.stdTableAdapter.Fill(this.tbl_userDataSet1.std); con.connect(); UpdateDeleteStudentForm up = new UpdateDeleteStudentForm(); string sql = "SELECT * FROM std WHERE fname like '" + SfName + "' "; SqlCommand cmd = new SqlCommand(sql); dataGridView1.ReadOnly = true; DataGridViewImageColumn pigcol = new DataGridViewImageColumn(); dataGridView1.RowTemplate.Height = 80; dataGridView1.DataSource = st.getStudents(cmd, con); pigcol = (DataGridViewImageColumn)dataGridView1.Columns[7]; pigcol.ImageLayout = DataGridViewImageCellLayout.Stretch; dataGridView1.AllowUserToAddRows = false; }
private void dataGridView1_DoubleClick(object sender, EventArgs e) { UpdateDeleteStudentForm up = new UpdateDeleteStudentForm(); up.textBox1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); up.textBox2.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString(); up.textBox3.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); up.dateTimePicker1.Value = (DateTime)dataGridView1.CurrentRow.Cells[3].Value; if (dataGridView1.CurrentRow.Cells[4].Value.ToString() == "Female") { up.radioButton2.Checked = true; } up.textBox4.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString(); up.textBox5.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString(); byte[] pic; pic = (byte[])dataGridView1.CurrentRow.Cells[7].Value; MemoryStream picture = new MemoryStream(pic); up.pictureBox1.Image = Image.FromStream(picture); up.Show(); }