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]` 与列表视图不同,我如何将其转换为用户可读的字符串类型,它位于组合框中。