In this case it'd be better to implement a list or collection (for instance, derive from CollectionBase) and override the indexer or even add your own so that in the get accessor you enumerate your structs stored in the internal ArrayList (the List property inherited from CollectionBase, or your own if you just implement the necessary interfaces like IList, which inherits from ICollection, which inherits from IEnumerable) and find the struct with the name property equal to the value you pass, like so:
public MyStruct this[string name]
if (name == null) thrownew ArgumentNullException("name");
foreach (MyStruct s in List)
if (string.Compare(s, name) == 0) return s;
thrownew ArgumentException("The structure was not found.", "name");
Using just an array of your structs, you won't be able to do what you want unless you implement your own IComparer and call one of the Array.BinarySearch overloads which takes an IComparer implementation as a parameter.
Is there a generic way of saying "everything" in a parameter of an oleDbDataAdapter? For instance, if my query asks for all rows WHERE (Name = ?), and then later in my code somewhere I have
Adapter.SelectCommand.Parameters[Name].Value = "some name";
What could I put in place of "some name" that would just mean everything...or is it even possible? Also, what if Value wasn't expecting a string, what if it was a bool...what can I put to basically ignore this parameter? Thanks a bunch for any help. I tried looking it up, but I didn't know what to search for.
I'm creating a C# application that uses the Visio Drawing Control and Visio SDK.
Basically, I have a windows form with the Visio control on it and the user and drag and drop objects from the Visio stencil. I am managing the OnShapeAdd and the OnShapeDelete just fine.
My problem is I don't know how to detect the event when the user just moves a shape. I need to do this due to the logic of this application. I don't see anything like 'move' or 'drag' in VisEventCodes.
The documentation isn't specific on whether or not the ShapeChanged event is fired when a shape is moved, but since this would change the location properties of the shape then it's possible. Try handling the ShapeChanged event and see if that works.
You have to use Visio's Undo Manager to begin and end an undo unit scope. See Chapter 25, Using the Visio Undo Manager in Your Program[^] in the MSDN Library. This is in referene to the OLE automation interfaces exposed by Visio, which is what the .NET interop assemblies (RCWs) wrap. For instance, the ApplicationClass has a BeginUndoScope mentioned in the link above.
It works, but if I move a shape once the event is fired MANY times (ten or more). How can I make this event be caught only once for everytime i move a shape?
I could add a counter, but then I wouldn't be able to distinguish when the event is fired correctly from when it is fired because of this weird behavior of visio sdk, so how can I control this?
This is needed because what I do when the shape moves is a heavy process and this eats up time like crazy.
You can't prevent it from being fired so many times, but you could use a simple state variable to help performance and determine when the last event was fired over a period of time (using a timer, for example, a common approach to many such problems).
If these are not Control derivatives, then you have to implement the events yourself from their container. The container would receive these events and you'd have to use the MousePosition static property of a Control (and call PointToClient on that control with the coordinates from MousePosition since those are in screen coordinates). Using the returned Point you need to have a way to figure out which shape was clicked, and then cause it to fire it's own Click or DoubleClick events (which you'd have to implement) using the same timer concept I mentioned before.