1
A
回答
7
if(myListView.SelectedItems == null || myListView.SelectedItems.Count == 0)
{
}
查看ListView..::.SelectedItems Property瞭解更多信息。
編輯:根據MSDN文檔:
如果當前沒有選擇項目,一個 空 的ListView .. :: SelectedListViewItemCollection 返回。
所以不需要空檢查在這種情況下,你可以簡單地做:
if(myListView.SelectedItems.Count == 0)
{
}
相關問題
- 1. windows窗體幫助ERP項目
- 2. 需要線程幫助-C#Windows窗體
- 3. 請幫助在Windows窗體計算器
- 4. 窗體關閉幫助
- 5. Jquery/Javascript窗體幫助?
- 6. Python Urllib窗體幫助
- 7. MySQL和PHP - 窗體幫助
- 8. C# - 多個窗體幫助!
- 9. Xamarin窗體:在StackLayout中的ListView上佈局所需的幫助
- 10. onClick ListView幫助
- 11. Android Listview幫助
- 12. Windows窗體應用程序:網格視圖幫助文本
- 13. Infragistics,Net Advantage 10.3 Windows窗體,幫助文檔?
- 14. 如何檢測Windows窗體MessageBox中的幫助按鈕?
- 15. 我需要幫助UpdateForm(); (Windows窗體應用程序)
- 16. 如何將幫助添加到Windows窗體
- 17. .Net Windows窗體ListView OwnerDraw LargeImageList泄漏
- 18. 基本的PHP窗體幫助
- 19. Rails窗體幫助has_one belongs_to協會
- 20. jquery選項卡與窗體幫助
- 21. 使用codeigniter窗體幫助查詢
- 22. 幫助嵌入式BaseFormDoctrine窗體
- 23. ASP.NET窗體創建的一些幫助...
- 24. 基本的PHP窗體幫助(2)
- 25. jquery和動態窗體的幫助?
- 26. CursorLoader不填充ListView [幫助]
- 27. Android概念幫助ListView
- 28. Android中的listView幫助
- 29. 有關ListView的幫助
- 30. 轉換Windows窗體到Windows Metro窗體
你確定你要檢查空? – tanascius 2009-12-16 14:29:58
我認爲應該不需要測試null。那麼真的很難看。 – OregonGhost 2009-12-16 14:30:14
msdn:「如果當前未選擇任何項目,則返回空的ListView.SelectedListViewItemCollection。」 – tanascius 2009-12-16 14:31:39