Anas Albakri

Anas Albakri

  • 2.1k
  • 11
  • 334

count a word in dataGridView

Aug 6 2022 11:05 AM

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<DataGridViewRow>() 
                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

Answers (5)