Hopefully you have used a
DataTable
as the data source for your
DataGridView
.
Then you can use this method to get the
IQueryable
interface from the data table.
DataTable dt = datagridview1.DataSource;
var query = dt.AsEnumerable().AsQueryable();
double average = query.Average(row => (int)row["column_name"]);
As for other statistical calculations you can use this CP article as a guide
Using LINQ to Calculate Basic Statistics[
^]