|
Cursor.Current = new Cursor("MyCursorFile.cur");<br />
Note that the Cursor class is limited to non animated two color cursors.
|
|
|
|
|
where must I place the MyCursorFile.cur for C# to be able to access it? Two-color only?
|
|
|
|
|
Put it in the same folder as the executable of your application.
You can also specify an absolute path "C:\\MyCursorFile.cur"
|
|
|
|
|
I am trying to close a form from using this.close inside of an if statement. The if statement is inside of an button_click event. Whne I run the debugger, the apppliction continues through the this.close() command. Here is the code:
DialogResult result = MessageBox.Show(m_strEmpName + " " + DateTime.Now + " Is this correct?","Sign In", MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (result == DialogResult.No)
{
result = MessageBox.Show("Please Re-enter","Error",MessageBoxButtons.OKCancel);
if (result == DialogResult.Cancel)
{
Reader.Close();
conn.Close();
this.Close(); //continues after this
}
}
What am I missing here?
Thanx in advance!
|
|
|
|
|
The form should close correctly but the function will nevertheless continue running until completed. If you walso want to exit the function you will need an additional return; statement.
|
|
|
|
|
Hi,
I find some trouble in implement a managed C++ interface in my C# project, but I can call the static method of a managed C++ class in the same C++ project from my C# project. When I implement the C++ interface, the error is:
-----------------------------------------------
COM Interop registration failed. Could not find a type library for assembly 'MyCSharp'.
-----------------------------------------------
How can I get the type library and why this happened? The basic code is:
C#:
public class FormDelegater : WiDSAddinView.IWiDSForm
{
public void NotifyViewHandler(string funcName, int node, uint LC){
//TODO: ...
}
}
-----------------------------------------------
C++:
public __gc __interface IWiDSForm{
void NotifyViewHandler(String* funcName, Int32 node, UInt32 LC);
};
Thanks a lot!
Dilly
|
|
|
|
|
The first parameter is a string pointer. Declare it as "ref string" in the C# code.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for help, but the following code is generated by the .NET2003 automatic. If I add a "ref" before the "string", the compiler will tell me that I did not implement the NotifyViewHandler() method.
In another case I modified the interface to an abstract class, and the compiler shows no error, but all the global variables and functions in managed C++ code are "out of scope" at runtime. Looking the code below:
_________________________________
C++:
public __gc __abstract class PWiDSForm
{
public:
virtual void NotifyVIewHandler(String* funcName, Int32 node, UInt32 LC) = 0;
};
__________________________________
C#:
public class WF : WiDSAddinView.IWiDSForm
{
#region IWiDSForm Members
public void NotifyVIewHandler(string funcName, int node, uint LC)
{
// TODO: Add WF.NotifyVIewHandler implementation
}
#endregion
}
Dilly
|
|
|
|
|
tiancaidao wrote: COM Interop registration failed. Could not find a type library for assembly 'MyCSharp'.
Why are you using COM? You dont need it. I just did the following and it works.
MC++
namespace interface1
{
public __gc __interface IMyInterface
{
void NotifyViewHandler(String* funcName, Int32 node, UInt32 LC);
};
}
C#
class Test : interface1.IMyInterface
{
public void NotifyViewHandler(string funcName, int node, uint LC)
{
}
}
I just added the dll produced by the MC++ code to the C# project referencing it.
|
|
|
|
|
Oh, yes, you are right.
I created a new solution in .NET2003 and two new projects just now, with C# and C++, they work fine, but my original solution which contains a C# addin still has the error. I use ActiveX in another project in the same solution, and my C# addin project depend on it, like this:
projects:
1.VSUserControlHost--ActiveX
2.AddinProj----C# addin
3.ClassLib----MC++ Class Library
2 is depend on 1 and 3, I define the MC++ interface in 3 which has no relations with 1, my error comes from here?
The compile option went wrong?
And I can not find "/clr" in command arguments, is this abnormal?
Dilly
|
|
|
|
|
tiancaidao wrote: The compile option went wrong?
What is the exact error u are getting? You make no reference to this. We can only guess then, and we dont like to guess.
tiancaidao wrote: And I can not find "/clr" in command arguments, is this abnormal?
It's available at 2 levels, per project and per file. IIRC if its enabled at project level u dont see it file level (or vica versa).
|
|
|
|
|
In fact the error still is this:
COM Interop registration failed. Could not find a type library for assembly 'MyCSharp'.
I do use COM neither in my MC++ project nor the C# project, but when I implement C++ interface with C# exactly like what you has written above, the error comes.
All things go fine, when I do not do the implementation in C#.
(The C# has a reference VSControlHost.dll which is built from an ActiveX(COM/COM+) project, but I don't think this matters.)
And so far, you have help me a lot, Thanks very much!
Dilly
|
|
|
|
|
I forgot to mention, try viewing the output of the MC++ project in Reflector.
|
|
|
|
|
how can i sort treenodes in my treeView by similar text? NOT tView.Sorted = true , but by actually removing the duplicate nodes and adding their children to the 'new' parent node.
Current:
+node1
+node2
+node2
+node2
+node2
+node3
+node3
+node4
+node4
+node5
Desired:
+node1
node2
|_subnode1
|_subnode2
|_subnode3
node3
|_subnode1
+node4
+node5
|
|
|
|
|
How are you building the list? I think it would be easier to sort the list out as you find data rather than sorting it later. I'm working on a similar problem myself at the moment, I'll let you know what I come up with when I solve it.
|
|
|
|
|
It's simple. When you build your tree you should remember the last rootnode (R) added. If the text of the new node (N) is like the text of R then you have to add N to R instead of adding it to the tree. If the text isn't the same then you have to add N to the tree and remember it as R.
Greetings,
Ingo
------------------------------
A bug in a Microsoft Product? No! It's not a bug it's an undocumented feature!
|
|
|
|
|
Well, thanks for the effort, but it doesn't work.
and the reason is due to the a problem i think related to when or how i am calling my 'new TreeNode', as i am only replacing the text of the previous node with the 'next' nodes text.
so in other words when i get to the point of adding new subnodes i only end up with one node.
if you care to see my original code look here:[^]
This is how i modified my orginal code to receive these results:
if (rootNode == DeptNode.Text)
{
if (modelTag == rootTag)
{
if (modelNode == ModNode.Text)
{
if (ModNode.Nodes.Contains(TelNode))
|
|
|
|
|
Is there a simpler way of creating a floating toolbar in C# (Like the one in adobe photoshop) rather than the complex sample codes I have seen?
Thanks a lot!
-- modified at 20:47 Wednesday 8th February, 2006
|
|
|
|
|
|
You could buy a complete component...
|
|
|
|
|
|
hi
how can i change datagrid1.forecolor in form1 form form2 -> i was tested a lot of ways ( public modifires and ...)and don't got result please help me ...
|
|
|
|
|
You really should not be doing that. Form1's controls should only be modified by code on Form1. Since you're trying to get code on Form2 to modify Form1, Form2 can now never exist without an instance of Form1 being present and known to Form2. This is just plain bad practice.
You can expose a Public Event on Form2 to trigger a subscriber to do something. The event would be fired by Form2 based on some condition. It doesn't case about what type the subscribers are, nor care if there are any subscribers. Using this model, it's up to Form1 to decide if it wants to subscribe to this event and do anything when it fires.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Take a reference of Form1 in Form2?
Dilly
|
|
|
|
|
Anyone got a good/fast 128-bit signed integer implementation in C#?
Many thanks!
Gywox
|
|
|
|