When you select a data(row) from datagridview1 the results that has those data from the database will appear in the listview1.
They will filter and sort the selected data.
For example:
-You select a symptoms
-Coughing
-The results(name of the disease) that has a coughing symptom that you selected in the datagridview1 will automatically display in the listview1.
-You select another symptom
-Wheezing
-The results(name of the disease) that has coughing and wheezing that you selected in the datagridview1 will automatically display in the listview1 and those who doesn't have those data will automatically disappear.
I think it's like when you select that word. They will find it in the database table. Like the word cough or wheezing or even the letters only. And it will automatically display it in another datagridview.
The results are also in the database.
They will get those data in the database(MySql)
I'm planning to just get those data in my dictionary table in database. And there are columns like the name of the disease, causes, symptoms, treating and etc.
But the only column that I just want to get the data from are only symptoms and the name of the disease.
I really don't know the syntax. I really don't know where to start. Please help. Thank you so much. I hope you can understand my question. :)
I tried coding it. Heheh. But everything is just so wrong.
What I have tried:
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count != 0)
{
con.Open();
cmd = new SqlCommand(@"Select * from DICTIONARY where Symptoms LIKE '%
{0}%'", con);
rdr = cmd.ExecuteReader();
if (rdr.Read())
{
dataGridView1.Rows.Add(rdr[0].ToString(), rdr[1].ToString());
}
List<string> selectedRows = new List<string>();
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
{
string currentRow = string.Empty;
foreach (DataGridViewCell cell in row.Cells)
{
currentRow += String.Format("{0} ", cell.FormattedValue);
}
selectedRows.Add(currentRow);
}
for (int i = 0; i < selectedRows.Count; i++)
{
this.listview1.Items.Add(selectedRows[i]);
}
}
}