迭代DataGrid行 [英] iterate through DataGrid Rows
本文介绍了迭代DataGrid行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好。我有一个WPF格式的DataGrid,它的名字是myDataGrid。
我的应用程序也通过LINQTOSQL链接到数据库。
在我的数据库中我有一个表名为Message 。
在window_loaded中我知道:
myDataGrid.ItemsSource = Messages.ToList();
现在我需要遍历myDataGrid行。
但是我不知道怎么做?
Hi. i have a DataGrid in a WPF form and its name is myDataGrid.
also my application is linked to database by LINQTOSQL.
in my databse i have a table is named Message.
in window_loaded i wrtie this:
myDataGrid.ItemsSource=Messages.ToList();
now i need iterate through myDataGrid Rows.
but i don''t how to do it?
推荐答案
你可以试试这个简单的方法:
You can try the simple way:
foreach(DataGridViewRow dr in MyDataGridView.Rows)
{
// do stuff with the row dr
}
干杯,
Edo
Cheers,
Edo
这篇关于迭代DataGrid行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文