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[])
不用漸變了