0
private void GetRecDept()
{
cmbDept.Items.Clear();
ListViewMeasurements.Items.Clear();
SFCDataContext SFC = new SFCDataContext();
try
{
var query = (from i in SFC.Systems_SettingsMeasurements
orderby i.RowID descending
select new {
RowID = i.RowID,
Measure = i.Measurement,
Target = i.TargetPercentage,
Dept = i.Department_ID
});
foreach (var w in query)
{
ListViewItem List = new ListViewItem(w.RowID.ToString());
List.SubItems.Add(w.Measure);
List.SubItems.Add(string.Format("{0:n2}", w.Target));
List.SubItems.Add(w.Dept);
ListViewMeasurements.Items.AddRange(new ListViewItem[] { List });
}
foreach (var r in query)
{
cmbDept.Items.Add(r.Dept.Distinct());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
及其對cmbDept.Items.Add()
輸出表示這種串的 System.Linq.Enumerable+<DistinctIterator>d__7a
1 [System.Char]`不像在列表視圖 我怎樣才能將其轉換爲一個字符串類型,可讀取到 用戶它在一個組合框中。實現C#的LINQ鮮明幫助以組表中的列