Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic about node select (Read 198 times)
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
about node select
Feb 27th, 2024 at 2:39am
Print Post  
node.selected = true
Executing the above code will result in the following exception
Sometimes it occurs and sometimes it does not, and I do not know the conditions.

---
    [例外] System.Private.CoreLib.dll!System.ThrowHelper.ThrowInvalidOperationException_Inv
alidOperation_EnumFailedVersion() 行 432  C#
    [例外] System.Private.CoreLib.dll!System.Collections.Generic.List<T>.Enumerator.MoveNex
t() 行 1130   C#
    [例外] MindFusion.Diagramming.dll!MindFusion.Diagramming.Selection.()  不明
    [例外] MindFusion.Diagramming.dll!MindFusion.Diagramming.Selection.Change(MindFusion.Di
agramming.DiagramItem item)    不明
    [例外] MindFusion.Diagramming.WinForms.dll!MindFusion.Diagramming.WinForms.Behaviors.Be
haviorBase.(System.Drawing.PointF )  不明
    [例外] MindFusion.Diagramming.WinForms.dll!MindFusion.Diagramming.WinForms.Behaviors.Be
haviorBase.OnMouseUp(System.Drawing.Point mousePosition, System.Windows.Forms.MouseButtons mouseButton)    不明
    [例外] MindFusion.Diagramming.WinForms.dll!MindFusion.Diagramming.WinForms.DiagramView.
OnMouseUp(System.Windows.Forms.MouseEventArgs e)   不明
    [例外] System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks) 行 12439    C#
    [例外] System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) 行 13229    C#
    [例外] MindFusion.Diagramming.WinForms.dll!MindFusion.Diagramming.WinForms.DiagramView.
WndProc(ref System.Windows.Forms.Message m)    不明
    [例外] System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMess
age(ref System.Windows.Forms.Message m) 行 67 C#
    [例外] System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndPro
c(ref System.Windows.Forms.Message m) 行 117  C#
    [例外] System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPt
r hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) 行 370 C#
    [例外] System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.Inter
op.Mso.IMsoComponentManager.FPushMessageLoop(System.UIntPtr dwComponentID, Interop.Mso.msoloop uReason, void* pvLoopData) 行 346  C#
    [例外] System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessa
geLoopInner(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) 行 1117  C#
    [例外] System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessa
geLoop(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) 行 981    C#
    [例外] System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.For
ms.Form mainForm) 行 1188 C#
    [例外] MainScreen.dll!Messiah.MainScreen.Program.Main() 行 14
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: about node select
Reply #1 - Feb 27th, 2024 at 7:35am
Print Post  
That could happen if you change selection state from NodeDeselected / LinkDeselected events. In that callstack they are raised within a loop over selection.Items; node.Selected setter modifies that collection, which .NET does not allow during enumeration.

If you are trying to prevent users from selecting or deselecting an item by toggling Selected property after the fact, try handling respective validation event instead, such as NodeSelecting. If you need to copy selection state of an item to other items, try doing that from SelectionChanged event handler, which is raised once for whole selection after the loop.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Nobu
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 24
Joined: Nov 27th, 2023
Re: about node select
Reply #2 - Feb 27th, 2024 at 8:19am
Print Post  
Thank you for your response.

I will try it.

Regards,
Nobu
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint