0

設定により、C#.NET で TreeView の外観をカスタマイズしました。

DrawMode=OwnerDrawAll; 

あれは、

OnDrawNode()  

オーバーライドされ、各ノードと接続線が正常に描画されます。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)).

次の手順でこの例外が頻繁に発生します。

  1. ツリービューに大きなテキストを含む 2 つのノードを追加します。
  2. RightToLeft および RightToLeftLayout プロパティを true に設定します。
  3. 「Nodes.Clear()」API を使用してすべてのノードを削除します。
  4. ツリー ビューに大きなテキストを含む 2 ~ 3 個のノードを再度追加します。

これを解決するアイデアはありますか?

4

1 に答える 1