5
Answers

count a word in dataGridView

Photo of Anas Albakri

Anas Albakri

2y
889
1

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)