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
C#
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

Vishal YelveRank #178 · 13.6K reputationPosted Aug 6, 2022, 8:21 AM EDT
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.
Jaydeep PatilRank #205 · 11.7K reputationPosted Aug 7, 2022, 1:13 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Aug 7, 2022, 4:45 AM EDT
test thislabel10.Text = (from Rows in dataGridView1.Rows.Cast() where !Rows.IsNewRow && Rows. Cells["x"].Value.ToString() == "Audi" select Rows).Count;Amit MohantyRank #112 · 20K reputationPosted Aug 8, 2022, 2:14 AM EDT
Uday DodiyaRank #239 · 10.3K reputationPosted Aug 8, 2022, 1:22 AM EDT