首页新闻找找看学习计划

TreeView繪製線性LinearGradientBrush 節點背景,導致程式閃退

0
悬赏园豆:5 [已关闭问题] 关闭于 2017-03-03 13:45

TreeView繪製線性節點,導致程式閃退,哪位大神幫忙看看
   protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            try
            {
  if (e.Node.IsSelected)
                {
LinearGradientBrush SolidB = new LinearGradientBrush(e.Bounds,Color.Blue, Color.Red, LinearGradientMode.Vertical); 
 SolidB.SetSigmaBellShape(0.5f);
 e.Graphics.FillRectangle(SolidB, e.Bounds); ---執行時直接導致程式退出,不拋出任何異常
}
  }
            catch (System.Exception ex)
            {
                LogHelper.WriteLog("OnDrawNode", ex.Message, "Err"); ;
                //throw ex;
            } 

系統異常
Application: MsgManager.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at System.Drawing.SafeNativeMethods+Gdip.GdipFillRectangleI(System.Runtime.InteropServices.HandleRef, System.Runtime.InteropServices.HandleRef, Int32, Int32, Int32, Int32)
   at System.Drawing.Graphics.FillRectangle(System.Drawing.Brush, Int32, Int32, Int32, Int32)
   at System.Drawing.Graphics.FillRectangle(System.Drawing.Brush, System.Drawing.Rectangle)
   at MsgMailControls.EmailNodes.OnDrawNode(System.Windows.Forms.DrawTreeNodeEventArgs)
   at System.Windows.Forms.TreeView.CustomDraw(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.TreeView.WmNotify(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.TreeView.WndProc(System.Windows.Forms.Message ByRef)
   at MsgMailControls.EmailNodes.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
   at System.Windows.Forms.UnsafeNativeMethods.SendMessage(System.Runtime.InteropServices.HandleRef, Int32, IntPtr, IntPtr)
   at System.Windows.Forms.Control.SendMessage(Int32, IntPtr, IntPtr)
   at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr, System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WmNotify(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.UserControl.WndProc(System.Windows.Forms.Message ByRef)
   at MsgMailControls.EmailTrees.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   at System.Windows.Forms.NativeWindow.DefWndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.DefWndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.TreeView.WndProc(System.Windows.Forms.Message ByRef)
   at MsgMailControls.EmailNodes.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
   at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
   at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
   at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
   at System.Windows.Forms.Application.Run(System.Windows.Forms.Form)
   at MsgManager.Program.Main(System.String[])

错误的过客的主页 错误的过客 | 初学一级 | 园豆:183
提问于:2016-12-19 13:09
< >
分享
所有回答(1)
0

不用漸變了

错误的过客 | 园豆:183 (初学一级) | 2017-03-03 12:03
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册