I am filling a datagridview with picture data (names, sizes), and trying to select certain rows.
The selection is done bases on the code on line#11 (which is OK for me!)
My problem is the fact that only 1 row is selected, but debugging the foreach on line #13 shows I should have at least two lines in my selection (today).
A short explanation on why this code is wrong would be appreciated 😉
Code:
int[] s = new int[100]; foreach (var fileName in Directory.GetFiles(folder)) { FileStream stream = File.OpenRead(fileName); Image i = Image.FromStream(stream, false, false); values[3] = i.Width; values[4] = i.Height; stream.Close(); int r = dataGridView1.Rows.Add(values); s[r] = (!(bool)values[5] && (int)values[3]>1000 ? r : 0); } var selection = from t in s where t > 0 select s[t]; foreach (var item in selection) { dataGridView1.CurrentCell = dataGridView1.Rows[item].Cells[0]; dataGridView1.Rows[item].Selected = true; }
My problem is the fact that only 1 row is selected, but debugging the foreach on line #13 shows I should have at least two lines in my selection (today).
A short explanation on why this code is wrong would be appreciated 😉
Comment