|
Is there a way to differentiate between an event that is fired from the mouse vs. programmatically...??? For example, I need to be able to differentiate between a mouse clicking a treeview checkbox vs. my code setting a checkbox.
If you set a checkbox in the code with this statement:
"node.Checked = e.Node.Checked;"
it triggers the treeview AfterCheck event, just as if you'd clicked it with the mouse.
I only want the event to be fired from a mouse click... is there a way to do this?
thanks.
|
|
|
|
|
A scenario I've used is with a global variable:
private bool m_ProgClick = false;
public void Foo()
{
...
m_ProgClick = true;
node.Checked = e.Node.Checked;
m_ProgClick = false;
...
}
protected void OnClick(...)
{
if (!m_ProgClick)
{
}
}
I've also used a stack to implement multiple places in the code that need to bypass the Click event (or other similar types of events). Write me if you want the details.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
Try this:
private void treeView1_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
if (e.Action == TreeViewAction.ByMouse)
{
MessageBox.Show("ByMouse");
}
}
|
|
|
|
|
Try digging into the event arguments that are passed to you.
e.something may identify that a mouse click occured. That way
your coding is based off what is passed to you in the event and
you become independant of internal code.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Please. I need to do a search for the not less or greater key than a specific value and using System.Collections like Hashtable, SortedList, ... in the same way as using STL map upper_bound and lower_bound functions. How could I do?
Thanks.
|
|
|
|
|
Same problem !!!
|
|
|
|
|
// Structs can be declared as arrays
// So can classes.
// But the classes don't work correctly?
using System;
namespace ConsoleApplication1
{
public struct myStruct
{
public int i;
}
public class myClass
{
public int i;
}
class Class1
{
static void Main(string[] args)
{
// WORKS OK
myStruct[] my_struct = new myStruct[10];
my_struct[0].i = 10;
// DOESN'T WORK
myClass[] my_class = new myClass[10]; // Can see the arrayed object in the Autos window...
my_class[0].i = 10; // error ... :
// An unhandled exception of type 'System.NullReferenceException'
// occurred in ConsoleApplication1.exe
// Additional information: Object reference not set to an instance of an object.
}
}
}
|
|
|
|
|
The classes do work correctly, just different.
If you create an array of a struct object, you get literally that, an array of that object. If you create an array of a class object, you get an array of references which all initialize to null .
You need to create the objects seperately (ie. my_class[0] = new myClass(); ) before you set the property.
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|
|
Thanks. I tried the identical thing for 2 hours but it wouldn't work.
Putting your sample in that example I gave, works.
I dont' know why my previous thing didn't work.
I will try to reproduce the error again and repost it. I suspect an IDE/compiler bug and/or an incorrect error message text from the compiler.
|
|
|
|
|
I need to analyse an entire Software-Package with a Database and Source-Code. So I'm looking for a Software to document the Software-Package Source Code and the Database; Which variables are used in which programm and which methodes are available and where to find them, what are the fieldnames in a database table...and so on.
Does anybody know a good Documentation-Software and where to get it?
Thanks
Stefan
|
|
|
|
|
this is basic but important.
VS.NET and .NET lang provides XML script document. you can create and write scripts in your programs and then after generate the document. this is xml output..
|
|
|
|
|
I have a .NET dll with some Windows Forms Control in it, and a .NET exe that uses a control in the dll.
How should I do to compile/join them into a SINGLE EXE, without the dll source?
Thanx.
|
|
|
|
|
Assembly Linker, look for al.exe in your SDK\bin directory.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
AL cannot "join" exe and dll.
thanks anyway, any other idea?
What AL.EXE Does Not Do
While shipping two closely related but separate DLLs is not that much of a bother, it would be nice if, since they are so closely intertwined, we could merge the two different assemblies into one. The ability to merge multiple libraries together would simplify deployment in many cases; applications that use many different languages or large applications written in the same language but built upon many different projects would benefit from single-assembly deployment.
You might, at this point, expect me to introduce AL.EXE (assembly linker) as the utility that can link multiple modules into a single file for deployment. While many developers new to .NET believe this is what AL.EXE does (and the MSDN seems to imply that this is what AL.EXE does) that is actually not the case. It is true that you can use AL.EXE to create a new assembly DLL that seems to combine two or more assemblies into one with the command line command:
al CSharpClass.netmodule VBClass.netmodule /target:library /out:combo.dll
(NOTE: don't worry about the "netmodule" extension just yet, we will discuss it in a moment. For the moment, pretend that the netmodule keyword is simply a DLL extension)
You can then take a client application that requires both classes (CSharpClass and VBClass) and link it only to combo.dll such that we can have:
csc client.cs /r:combo.dll
as opposed to:
csc client.cs /r:VBClass.dll /r:CSharpClass.dll
However, this may lead the developer to believe that he has combined the two assemblies into one, and he can simply ship combo.dll with his client, and not including VBClass.dll or csharp.dll. But this is not the case. In fact, the developer must now ship combo.dll AND CSharpClass.netmodule and VBClass.netmodule, otherwise his application will not run.
We can see then, that while AL.EXE might make our compilation simpler, it does not really save us anything from a deployment perspective. So what is AL.EXE good for? The answer is for working with what are known as modules and compiling them into an assembly. We will see in the section after next, modules come into play heavily when we are writing international applications.
|
|
|
|
|
Ahh, remebered there was a catch, what you can use though is ILLinker available on GotDotNet Works like a charm.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
|
How can I work in C# with Comm Port?
I need send some data to Comm Port and then read answer...
Please help me. Sorry my English.
|
|
|
|
|
Hint: search the MSDN Magazine site
VictorV
|
|
|
|
|
Hello everybody,
I have a concern, related to my superficial knowledge about Collections in C# (and of course .NET framework):
I had in my application two Queues:
System.Collections.Queue q1;
System.Collections.Queue q2;
First queue is filled by a working thread.
The main thread, process data from second queue.
What happen when I use q2 = q1 in my code?
Is q2 filled with elements from q1? Remain q1 and q2 two independet queues, or q2 will somehow point to q1 in fact, through some referrence mechanism?
Should I explicitely copy elements from q1 into q2, or assignment is sufficient?
Please help me with this situation, many thanks,
Miguel
|
|
|
|
|
In your example of using Queues, the operator "=" will do a reference assignment. Meaning, any changes to q2 will also show up in q1 and vice versa.
You will need to do explicit copying of the elements in order to duplicate the queues. Or you can do something like this:
q2 = new Queue( q1 );
This will do the duplicating for you.
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Thanks, now is clear about reference assignment.
Also thanks for pointing me in using this kind of constructor, which will do for me exactly what I want.
But one more question: if the content of the queues is different, at the moment of assignment, one of it will be lost, right?
Regards,
Miguel
|
|
|
|
|
Don Miguel wrote:
But one more question: if the content of the queues is different, at the moment of assignment, one of it will be lost, right?
Correct, when the assignment to q2 happens with the constructor method the data in q2 is effectively lost (atleast if you don't have references to the elements in q2 somewhere else).
q2 = new Queue( q1 );
<br />
foreach( object o in q1 )<br />
q2.Enqueue( o );
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Nathan Blomquist wrote:
the data in q2 is effectively lost
Thanks Nathan, is clear now.
|
|
|
|
|
Hi:
I would like to add DirectX reference to the C# project.I installed the DirectX9.0 SDK(for c#) already, but still not can find the DiretX reference. without that, i can not use namespace of DirectX, so can not continue work.
any boday have idea how to do?
thanks
henry
|
|
|
|
|
Project->Add Reference...
Select Microsoft.DirectX and any useful component parts (eg. Microsoft.DirectX.DirectDraw).
Paul
We all will feed the worms and trees So don't be shy - Queens of the Stone Age, Mosquito Song
|
|
|
|