|
Works perfectly Jay, thank you.
|
|
|
|
|
I have an array made up of a cutom structure called sl1. How can I find the index of the sl1 object, in the array, that has a name property equal to value I'm searching for? 
|
|
|
|
|
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]
{
get
{
if (name == null) throw new ArgumentNullException("name");
foreach (MyStruct s in List)
if (string.Compare(s, name) == 0) return s;
throw new 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.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
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. 
|
|
|
|
|
If you leave it blank, it should use all the values in your select statement
|
|
|
|
|
You'll get an exception since the parameter contained no value, thus leaving a SQL statement like this to be executed:
select * from SomeTable where Name = That doesn't parse correctly and therefore won't execute.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
When you use paramterized queries, you declare what type the parameter is. Value is an object so you can assign anything.
Because your query uses = and not LIKE , there's nothing you can really do other than have multiple SQL commands or command strings and use whichever is appropriate if you don't want to supply a value.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
PWLX_NOTIFICATION_INFO for winlogin notification package is defined in Winwlx.h file. how i will use it in C#, where i can't include header files ???
@!$h@
|
|
|
|
|
Wrong language - C and C++ allow you to include header files.
Find the header file, find the text you are looking for ("PWLX_NOTIFICATION_INFO") and find out what it equates to.
In C# write something like:
const uint PWLX_NOTIFICATION_INFO = 0x80001234;
or what ever the value might be. Then repeat for as many values in the set as there are.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
|
hi i want to know the matrix determinant yes there is a
cofactor method of determinant in3d matrix i think so is there any code for this
and
if there is 2d what is the code for 2d matrix determinant
matrix determinant
|
|
|
|
|
|
|
Hello everybody.
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.
Any help will be greatly appreciated.
Thanks in advance.
|
|
|
|
|
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.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you very much, but the ShapeChanged event never seems to get triggered!
Much as I move of reshape or edit the text in a shape, I never get it triggered! ????
|
|
|
|
|
I'm doing this inside my AddAdvise method:
newEvent = documentEvents.AddAdvise(<br />
(short)VisEventCodes.visEvtMod +<br />
(short)VisEventCodes.visEvtShape,<br />
(IVisEventProc)this, sink, targetArgs);
And it doesnt seem to work.
However, this works perfectly:
newEvent = documentEvents.AddAdvise(<br />
(unchecked((short)VisEventCodes.visEvtAdd) +<br />
(short)VisEventCodes.visEvtShape),<br />
(IVisEventProc)this, sink, targetArgs);
???
|
|
|
|
|
Use the PIA for Visio (Microsoft.Office.Interop.Visio.dll, which you can download from MSDN[^] for Office XP and which comes with Office 2003 Professional) and just handle the event like so:
ApplicationClass app = new ApplicationClass();
app.ShapeChanged += new EApplication_ShapeChangedEventHandler(OnShapeChanged);
private void OnShapeChanged(object sender, IntPtr args)
{
} I'm not sure if this will work, however. You mentioned in a previous reply that it doesn't seem to be firing. It was only an educated guess, since no other event really seems to be appropriate.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Thank you very much, it works great.
I have another question, though:
HOw can I produce an 'undo' programmatically?
|
|
|
|
|
I have tried:
Shape.Application.Undo();
and simply nothing happens.
And:
this.VisioContainerDesign.Window.Application.Undo();
And nothing happens either!
????
|
|
|
|
|
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.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
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.
ANY help would be greatly appreciated!
|
|
|
|
|
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).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm having problems with another event:
how can I detect a doubleclick on a Shape?
How about a rightclick on a shape?
....
(Any help would be greatly appreciatted)
Thanks a lot
|
|
|
|