0
我需要某段代碼來幫助我打印存儲在datagrid行或SQL數據庫圖像上的圖像,並且我想做一些有用的事情出來了。單擊datagridview行時在圖片框上顯示圖像
我的觀點是每次點擊數據行就插入圖像。
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Trabalhos\AuthMyRegistery\AuthMyRegistery\Data.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
id_Worker_Info = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["id_Worker_Info"].Value.ToString());
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Worker where id_Worker_Info='" +id_Worker_Info+ "';";
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
dataGridView1.DataSource = dt;
foreach (DataRow dr in dt.Rows)
{
WorkerIdTextBox.Text = dr["id_Worker_Info"].ToString();
NameTextBox.Text = dr["Name"].ToString();
FnameTextBox.Text = dr["Formation_Name"].ToString();
BirthTextBox.Text = dr["Date_of_Birth"].ToString();
}
}
什麼是您的具體問題? –