Hello how can i count a word in dataGridView like an example
i have a cars model
BMW, Audi, Mitsubishi, Mercedes .etc
i want a code to count how many bmw i have ,how many Mercedes i have. etc
in a lable.text
and i coded this
int x = 4;
label10.Text = (from Rows in dataGridView1.Rows.Cast()
where !Rows.IsNewRow && Rows.Cells(x).ToString == "Audi"
select Rows).Count;
Error 1
" Non-invocable member 'System.Windows.Forms.DataGridViewRow.Cells' cannot be used like a method "
wher's the error
Amit MohantyPosted Aug 8, 2022, 6:14 AM
Uday DodiyaPosted Aug 8, 2022, 5:22 AM
Sachin SinghPosted Aug 7, 2022, 8:45 AM
Jaydeep PatilPosted Aug 7, 2022, 5:13 AM
Vishal YelvePosted Aug 6, 2022, 12:21 PM
https://www.codegrepper.com/code-examples/csharp/c%23+datagridview+count+value
var count = this.dataGridViewArticles.Rows.Cast().Count(); var countjustX = this.dataGridView1.Rows.Cast().Count(row => row.Cells["RisFin"].Value == "X");this.textBox1.Text = count.ToString();
Try this give you count.