hi i am new to Linq Queries, And this code is copied from internet
object cells = from r in dataGridView1.Rows.Cast<DataGridViewRow>()where !r.IsNewRowArray.ConvertAll<DataGridViewCell, string>(r.Cells.Cast<DataGridViewCell>().ToArray, dgvc => dgvc.Value.ToString)where c.Contains(textBox1.Text)
select new cell {
rowIndex = r.Index,
columnIndex = Array.IndexOf(c, _textBox1.Text)};
and by using the following code i am fiding the string in a datagridview cell.
object cells = from r in dataGridView1.Rows.Cast<DataGridViewRow>()where !r.IsNewRowArray.ConvertAll<DataGridViewCell, string>(r.Cells.Cast<DataGridViewCell>().ToArray, dgvc => dgvc.Value.ToString)where c.Contains(_txt)
select new cell {
rowIndex = r.Index,
columnIndex = Array.IndexOf(c, _txt)
};
foreach (DataGridViewRow r in dataGridView1.Rows.Cast<DataGridViewRow>()) {
foreach (DataGridViewCell c in r.Cells.Cast<DataGridViewCell>()) {
if (!r.IsNewRow) {
c.Style.BackColor = Color.White;
}
}
}
foreach (object c_loopVariable in cells) {
c = c_loopVariable;
DataGridView1.Rows(c.rowIndex).Cells(c.columnIndex).Style.BackColor = Color.Red;
}
and changing the color of that cell.
And i want to find the first empty cell in datagridview i have (12 columns and 8 rows) my datagridview is filled by column wise. when it entering to the 8th row it is automatically goes to next column, Code is written below.Where _col and _row is declared globally
dataGridView1[_col, _row].Value = lvI.Text;
_row = _row + 1;
if (_row == 8)
{
_row = 0;
_col = _col + 1;
}
actually i am filling datagridview from listview. when i check the listview item the datagridview is filled based on column wise. when i uncheck it clears the datagridview cell which contains that text.
i can show the picture of my datagridview for better understanding
after uncheck it will be like this
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…