我創建了一個message
類爲我的用戶:進行分組的的BindingList
public class Message
{
[DisplayName("Message")]
public string shortContent { get; set; }
[DisplayName("Line")]
public int line { get; set; }
[DisplayName("File Name")]
public string file { get; set; }
[DisplayName("Level")]
public MessageLevel level { get; set; }
...
}
public enum MessageLevel
{
Information,
Warning,
Error
}
要顯示這對我愛的用戶,我把它綁定到一個自定義綁定列表(爲了讓他們的消息進行排序)。
我希望能夠通過一些屬性(level
,shortContent
本質上)將消息分組,但我找不到任何簡單的方法與Linq
。
我試過用GroupBy沒有運氣。我很想在於如何將這些:
Message Line File Name Level Date Read Full message
The device is not ready. 46 OpenFileControl.cs Error 24/09/2015 3:01 True
The device is not ready. 46 OpenFileControl.cs Error 24/09/2015 3:02 True
Some Random message. -1 Unkown Error
到:
Message Count
The device is not ready. 2
Some Random message. 1
使用'GroupBy'時什麼不適合你? –