In my form I have taken one combobox where I use to display the Plantname
and on click event of button control Im retrieving the related information from the database . I have used datagridview for data display . I also want to display the plant images in a datagridview . Its is possible in web application but how to do it in a window application.
I'm able to display values in the datagridview and when i click on the particular cell that value of the text get copied to textbox1.text ..
Now i want the image of that same name which got displayed at textbox1..I have used one picture box where on clicking the datagridview cell or textbox the images get displayed one after one im using the code below
private void Disease_Load(object sender, EventArgs e)
{
String constring = "Data Source=|DataDirectory|abc.mdb;Jet OLEDB:Database Password=abc#;Provider=Microsoft.jet.oledb.4.0";
OleDbConnection conn = new OleDbConnection(constring);
OleDbDataAdapter da1 = new OleDbDataAdapter("Select Distinct DCured from Diseases", conn);
DataSet dset1 = new DataSet();
da1.Fill(dset1, "Diseases");
if (dset1.Tables["Diseases"].Rows.Count > 0)
{
comboBox1.DataSource = dset1.Tables["Diseases"];
comboBox1.DisplayMember = "DCur";
comboBox1.ValueMember = "DCur";
comboBox1.SelectedIndex = 0;
//IHBT(CSIR)
}
conn.Close();
}
private void button2_Click(object sender, EventArgs e)
{
try
{
String Constring = "Data Source=|DataDirectory|abc.mdb; Jet OLEDB:Database Password= abc#; Provider=Microsoft.jet.oledb.4.0";
OleDbDataAdapter da3 = new OleDbDataAdapter("SELECT Photograph.Photographs,Diseases.SName AS SName FROM (Systematics INNER JOIN Photograph ON Systematics.[ID] = Photograph.[ID]) INNER JOIN Diseases ON Systematics.[SName] = Diseases.[SName] Where DCured='" + comboBox1.Text + "'", Constring);
DataSet dset3 = new DataSet();
da3.Fill(dset3, "RIT");
if (dset.Tables["RIT"].Rows.Count > 0)
{
dataGridView2.DataSource = dset.Tables[0];
dataGridView4.DataSource = dset3.Tables[0];
textBox1.Text = dset3.Tables["NIT"].Rows[0]["Photographs"].ToString();
pictureBox1.Load(Application.StartupPath + "//" + textBox1.Text);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "NIT", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
}
}
private void dataGridView4_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
textBox1.Text = Convert.ToString(dataGridView4.CurrentRow.Cells["Photographs"].Value);
}
reply if anybody know the answer