0
我已經通過設置NullReference異常
DrawMode=OwnerDrawAll;
即,
OnDrawNode()
定製樹視圖在C#的.NET的外觀將被覆蓋並繪製的每個節點和連接線成功。除了我經常得到一個NullReference消息外,每件事情都很好。以下是堆棧跟蹤
at System.Windows.Forms.TreeNode.get_Handle()
at System.Windows.Forms.TreeNode.get_RowBounds()
at System.Windows.Forms.TreeView.CustomDraw(Message& m)
at System.Windows.Forms.TreeView.WmNotify(Message& m)
at System.Windows.Forms.TreeView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The message send to the WndProc during the exception is "WndProc(ref System.Windows.Forms.Message message = {msg=0x204e (WM_REFLECT + WM_NOTIFY)).
通常我得到這個例外以下步驟:
- 添加2個節點有大量的文字到TreeView。
- 將RightToLeft和RightToLeftLayout屬性設置爲true。
- 使用「Nodes.Clear()」API刪除所有節點。
- 再次在樹視圖中添加2-3個大文本節點。
任何一個有任何想法解決這個?
可以共享代碼,你建的樹? – nhrobin
在某一時間(例如,當窗體是不可見的)添加到'treeview'節點可能會導致此異常。 –
@KingKing表單總是可見的。 – NidhiSree