|
Hmm.. sounds like a homework project to me.
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
In the tree of the WindowsExplorer, when we click on a node and choose 'rename', the text of that node, maybe, appear in a textbox and we can change that text.
Can u show me how to do that in C#?
Please help me!
Thank you in-advanced!
|
|
|
|
|
gyokusei wrote:
Can u show me how to do that in C#?
So, what you are saying here is that you want to simulate this effect on a listview control (or similar controls) into your application (WinForms I suppose)? Or you want access the shell?
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Just set the LabelEdit property of your TreeView to true and you'll be able to edit it by clicking on it. If you want to trigger an Edit manually use TreeView.BeginLabelEdit().
|
|
|
|
|
this.treeTemplates.SelectedNode.BeginEdit();
GanDad
|
|
|
|
|
Hi!
I'm currently trying to improve the speed of my xml library TXML, which does not rely on any XML base classes and thus parses the XML string itself to find a certain node.
Because of this I'm interested in finding the fastest way of checking the equality of two strings. On various sites I've read that String.Equals() is supposed to be faster than the == operator, which uses String.op_Equality() under the hood. So I replaced all == comparisons in a certain method with String.Equals() comparisons. The weird thing is that the new code with String.Equals() appears to run 100 ms on average slower than the old code with ==. Can anyone explain me why?
Here's the code of the above mentioned method:
private ReaderReturnValue GetNodeContent(string masterNode, int mnIndex, string subNode, int snIndex)<br />
{<br />
int mi = 1;
int si = 1;
int mnLength = masterNode.Length;<br />
int snLength = subNode.Length;<br />
int textLength = 0;
int i = 0;
int snBegin = 0;
bool foundMn = false;<br />
bool foundSn = false;<br />
bool done = false;
<br />
if(masterNode == "")
foundMn = true;<br />
<br />
for(i = 0; i < XmlText.Length; i++)<br />
{<br />
if(XmlText[i] == '<')
{ <br />
<br />
if(foundMn == false)
{<br />
if(mnLength + 1 <= XmlText.Length - i - 1)
{<br />
if(XmlText.Substring(i + 1, mnLength + 1).Equals(masterNode + '>'))
{<br />
if(mi == mnIndex)<br />
foundMn = true;<br />
else<br />
mi++;<br />
}<br />
}<br />
}<br />
<br />
if(foundMn == true && foundSn == false)
{<br />
if(snLength + 1 <= XmlText.Length - i - 1)
{<br />
if(XmlText.Substring(i + 1, snLength + 1).Equals(subNode + '>'))
{<br />
if(si == snIndex)<br />
{<br />
foundSn = true;<br />
snBegin = i + snLength + 2;
}<br />
else<br />
si++;<br />
}<br />
}<br />
}<br />
<br />
if(mnLength + 1 <= XmlText.Length - i - 1)
{<br />
if(foundMn == true)
{<br />
if(XmlText.Substring(i + 1, mnLength + 2).Equals('/' + masterNode + '>'))
break;
}<br />
}<br />
<br />
if(foundSn == true)
{<br />
if(mnLength + 1 <= XmlText.Length - i - 1)
{<br />
if(XmlText.Substring(i + 1, snLength + 2).Equals('/' + subNode + '>'))
{<br />
done = true;<br />
break;<br />
}<br />
else<br />
textLength++;<br />
}<br />
}<br />
<br />
}
else<br />
{<br />
if(foundSn == true)
textLength++;<br />
}<br />
<br />
}
<br />
ReaderReturnValue returnValue = new ReaderReturnValue();<br />
<br />
if(done == true)
{<br />
returnValue.text = XmlText.Substring(snBegin, textLength - snLength - 2);<br />
returnValue.foundNode = true;<br />
} <br />
else<br />
returnValue.foundNode = false;<br />
<br />
return returnValue;<br />
}
|
|
|
|
|
I looked at the implementation of op_Equality and Equals. It looks like op_Equality ends up calling Equals in its implementation, after doing some null checking. I don't know why calling op_Equality is faster.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Due to some misconfiguration in my Profiler I originally thought op_Equality() to be faster, which in fact isn't the true case. Apparently the null checking that is performed in op_Equality() makes it a little slower than Equals().
Thanks for your help!
|
|
|
|
|
i've got two form, when i clicked a button on the first, it opened the second. How could i interact with the first from the second, i mean Could i reference to a windows form from another
Thanks in advance
|
|
|
|
|
vuthaianh wrote:
Could i reference to a windows form from another
Ofourse you can. A form is a class like everything else. If you have assigned public variables or methods in the class you want to access then you can access them from any other class in your solution.
E.g. you have 2 classes, Form1 and Form2 and you want to access Form2 from Form1.
(1) First of all you create one instance of each class:
Form1 <code>myFirstForm </code>= new Form1();
Form2 <code>mySecondForm </code>= new Form2();
(2) Assuming that you have publicly available fields or methods in Form2 then you can access them from any class, including Form1. So if you wanted to call a method located inside Form2 from somewhere within Form1 you could say:
int <code>myRate </code>= mySecondForm.CalculateRate();
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
One thing that Polis didn't mention was the use of events and delegates. You can hook into events that another form (i.e., FormB) exposes to notify your main form (i.e., FormA). This will allow you to maintain private methods across both forms and still transfer data.
|
|
|
|
|
Yes, Nick makes a good point there with events and delegates. I guess the rest is up to you
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
How do I execute a stored procedure in the Page_Load function of C#?
Thanks!
Illegal Operation
WannaBe and GonnaBe Systems Developer
|
|
|
|
|
|
thanks for the help.
Just one more question?
Where does the "myReader" fit into the picture? I have inserted the line:
myReader = MyProc.executeReader();
Thanks!
Illegal Operation
WannaBe and GonnaBe Systems Developer
|
|
|
|
|
|
I have an item that is a tag value to a list view, and the list view item is also contained in the object. The relationship is two way.
My question is, if i remove these objects, will it persist in memory due to the fact that they refference each other?
From what i've read of the Garbage collector, it will perform a graph search for all objects reachable from root objects. So even if my two objects DO refference each other, they will be removed if they are unreachable from the root objects.
Is this right?
Cheers
Cata
|
|
|
|
|
That's right. It will remove them.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hi, is it possible to include the myApp.exe.manifest file in the exe file so that I don't have to have two separate files, one exe and one manifest? If so, how should I do this? (Visual Studio .NET 2003, C#)
|
|
|
|
|
|
hi,
i have made a service wich loads a another program ,my codes are correct but when i use these codes in my service,they dont work.
here is my codes:
<br />
System.IO.Directory.SetCurrentDirectory(myappPath);<br />
Process.Start("MyApplication" );<br />
i want to know why it happens?
|
|
|
|
|
What does not work?
Does the application not start? Have you checked with the TaskManager if it really does not start or is it started and you can't just see it?
Normally, a service application cannot interact with the desktop. Because of that, if you start an application from a service, the application will not be visible to the user.
To allow a service to interact with the desktop open the Service Control Manager. Select your service and open the properties.
- Select the "Log On" tab
- Select "Log on as: Local System account" and enter a valid account and password
- Check "Allow service to interact with desktop.
hth
Claudio
Claudio's Website
Hommingberger Gepardenforelle
|
|
|
|
|
Hi folks,
I need to write a piece of code that will list all the files in a folder in another machine.
Could you guys give me a hint?
Thanks.
|
|
|
|
|
you can set up the sharing on the another computer and access the directory directly using System.IO.Directory or make some sort of simple service which will send the data on request via tcp/ip protocol.
|
|
|
|
|
1.Value types are allocated on stack and Reference types are allocated on heap,managed by garbage collector.
if reference type contains value type as a member,where does meomory allocated for value types?
eg: class employee
{
int i; //stack or heap? or some boxing?
}
2.Value types are initialized to zero or null. does reference type member variables are initialized to zero or null?
Thanks
Viny.
|
|
|
|