C Sharp And Ms Access Database Tutorial 12 How To Display Selected Row From Datagridview To Textboxes On Cell Click

C# And Ms Access Database Tutorial #12 – How To Display Selected Row From Datagridview To Textboxes On Cell Click

VIDEO TUTORIAL

C# And Ms Access Database Tutorial #12 – How To Display Selected Row From Datagridview To Textboxes On Cell Click

This Tutorial Shows How To Display Selected Row From Datagridview To Textboxes And Picture Box On Cell Content Click In C# Windows Forms Application using visual studio 2010.

How To Display Selected Row From Datagridview To Textboxes On Cell Click
How To Display Selected Row From Datagridview To Textboxes On Cell Click

C# SOURCE CODE

        //Display Selected Datagridview Row Content On Input fields (Textboxes, PictureBoxes etc..)
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //If DataGridViewRow Is clicked
            if (e.RowIndex >= 0)
            {
                DataGridViewRow selectedDataGridViewRow = dataGridView1.Rows[e.RowIndex];

                txtID.Text = selectedDataGridViewRow.Cells[0].Value.ToString();
                txtFullName.Text = selectedDataGridViewRow.Cells[1].Value.ToString();
                txtEmailAddess.Text = selectedDataGridViewRow.Cells[2].Value.ToString();
                txtPhoneNumber.Text = selectedDataGridViewRow.Cells[3].Value.ToString();
                txtLanguage.Text = selectedDataGridViewRow.Cells[4].Value.ToString();
                txtCountry.Text = selectedDataGridViewRow.Cells[5].Value.ToString();
                txtgender.Text = selectedDataGridViewRow.Cells[6].Value.ToString();
                txtImagePath.Text = selectedDataGridViewRow.Cells[7].Value.ToString();
                //Convert Byte Array To Image
                pictureBox1.Image = convertByteArrayToImage((byte[])selectedDataGridViewRow.Cells[8].Value);
            }
        }
READ MORE  How To Create A System Restore Point In Windows 10

Leave a Reply

Your email address will not be published. Required fields are marked *