Hi,
This is couple part question.
1) I have a listbox populated from the database, and I have a gridview populated from database.
Both listbox and a gridview have one common column. I would like to programmatically highlight all the rows of the gridview to green if both listbox and gridview have that ID.
so I wrote this procedure:
public void highlight() { try {//this only works if I select a row from listbox. I need this for every row string projectano = lbinvoicenames.SelectedValue.ToString();
foreach (DataGridViewRow row in gvinvoices.Rows) { if (row.Cells[0].Value.ToString() != null) { if (projectano == row.Cells[0].Value.ToString()) { counter = Convert.ToInt32( gvinvoices.selectedindex.ToString()); row.DefaultCellStyle.BackColor = Color.Green; //gvinvoices.CurrentCell = gvinvoices.Rows[row.Index].Cells[0]; } if (row.DefaultCellStyle.BackColor != Color.Green) { } } } } catch { } }
2) The second part of the question is if the row is not higlighted to green move them to the top.
3) And the last question.
I read files from a directory and load them to a separate listbox. My gridview contains a column with a unique number. That unique number is a part of the naming of the pdfs. I would like to be able to highlight the row of listbox with file name where unique number is the number from the gridview.
Any help?
Thank you,