|
thanks. EndEdit works fine.
|
|
|
|
|
In the tree view if one node is clicked (when selected), can we change the background color of that perticular node?
pls guide
regards
|
|
|
|
|
You can change TreeNode.BackColor, if the node is clicked twice:
<br />
treeview_AfterSelect(...){
treeview.selectedNode.BackColor = SystemColors.Highlight;<br />
}<br />
<br />
treeview_Click(...){<br />
treeview.SelectedNode.BackColor = Color.Red;<br />
}<br />
|
|
|
|
|
This already happen by default. If you seem to be losing that background color when the TreeView doesn't have the focus, then set TreeView.HideSelection to false . The default is true .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks your guidance.
Continuing the same topic; if I click nodes of the tree view, I want to add some runtime check boxes, radio buttons, numerical up down, combo box and text boxes that will be different for different nodes. For example, when I go to node 2 from node 1 I want to preserve the states of the controls corresponding to it so that when I again come back , I should get the earlier state. As I have more than 75 different controls and its not practical to have that much variables for each control. Is it OK if I use Hashtable in this situation or is there any other better way of dealing with such a situation.
moreover
How to select node of a TreeView Control by name in C#? i.e. is there any method that takes node name as a parameter and returns node?
please guide.
regards
|
|
|
|
|
Some of what you want to do is very difficult. The TreeView class encapsulates the Tree-View Windows Common Control, so everything comes down to sending messages, marshaling structs, and the like. Other things you want are impossible (like nodes having different check boxes, radio buttons, etc.
For that, look into a third-party control like UltraWinTree from Infragistics[^].
As far as selecting a node in C#, you should read through the documentation. It's really quite simple: set TreeView.SelectedNode to the TreeNode you want to select.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
oh !!
I am very sorry for the incomplete information, I did'nt mean to add controls to the tree view. I will divide the form in two parts, in the left half I will have tree view and in the right half i will add/remove at runtime according to the node that is selected. In this situation if corresponding to Node 1 if I add 3 check boxes in the right half of the form at runtime and check 2 of them, then I select Node 2, that will add a few controls check/uncheck them and go to some other node, I want to save the status of the corresponding controls such that when I come back to those nodes, I should know I did last time to them.
Shall I use Hash Table or resource file (as the total number of controls are above 70). I want to save the status even if I exit from the application, so that when I open it again I will get to know what I did last time.
please guide.
regards
|
|
|
|
|
We have an online mail application. What we want is to make this the default e-mail client so that if people right-mouse click a file in explorer and select send to mail receipt it will open up windows explorer and points to our mail address.
We read many acticles on the internet on how we have to change the registry settings from i.e. Outlook to Outlook Express which seems to work fine. But if we change the settings to our online application, nothing happens.
Our client can download a client application (written in C#) which automatically check whether e-mails arrives. We now want to give the client an option in this applicatoin to make the online mailsystem the default e-mail system.
Question: Is someone able to tell me whether I need to build a DLL for this (preferably in C# as all other code is written in C#) and how to get this to work as we don't seem to be able to figure this out?
Many thanks, Lieperik
|
|
|
|
|
The default mail client is typically a MAPI client. However, Windows XP and higher supports setting a web provider as the default. I'm not sure on the specifics (never cared to look) but you could browse the registry and look for information about the Hotmail provider, since Hotmail can be the default mail client on Windows XP. Maybe there's a small MAPI stub - I really don't know. At least digging through the registry entries you already know about after setting Hotmail as the default client might give you some insight.
As a potential user of your system (speaking hypothetically, of course), I deserve the right to set whatever I want as my default client. Forcing users to use something - unless your a domain admin or something - is a quick way to piss people off and loose them. You might look at how to register your web mail provider like Hotmail is and prompt them during installation to set you as the default mail provider.
[EDIT] Oh, this MAPI stub would have to be a native DLL that exports functions, though you could use this as a stub to a .NET assembly by exposing your components as CCW (COM-Callable Wrappers). [/EDIT]
In the worst case scenario, you will have to create a MAPI stub that basically interprets MAPI calls and forwards them to your web mail provider appropriately.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I have a Windows Service that needs to write to the event log. For security the service will not be running as system, but in an account that has less privileges so that it can't be forced to do things it shouldn't be doing.
The net result of this is that the EventLog no longer works. Can anyone point me in the right direction for creating and writing to an event log with less than administrator privileges. We are trying to trim the security back to the minimum required, and all it needs is to access a SQL Server and read and write files to specific directories.
Also, it will be installed on Win XP Pro and Server 2003 - If that makes any difference.
|
|
|
|
|
Create an acount with proper privilage , then in your service you can Impersonate() to that account. There is a sample code in MSDN for this method.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Thanks for your response.
I'd rather not have any accounts with Admin Privilege that the Windows Service uses. Also, assuming that this[^] is the sample you are refering to, I don't want passwords to be kept anywhere in the application or its config as that presents an additional security risk.
Is there any other solution?
|
|
|
|
|
The security required depends on the EventLog that your writing to. A normal user can't write to the SYSTEM or SECURITY logs but can write to the APPLICATION LOG. Also, your app can create it's own event log and write to it, but I'm not sure on the permissions of creating the log.
The user account you create for the service doesn't have to be an administrator account and the username and password are stored with the Service Control Manager. You don't have to store these seperately yourself. When your service is launched, it will be running under the account you provide. Your service won't have to do any seperate authentication to get additional privileges.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I need to netsend a message to approx 40 wan locations. I allready had a class (vb6) for that. De class had the following properties to set:
.message (message to be send)
.sendto (domain/user)
.sendfromserver (from which server to send the message).
Basicly the tool tells the server at a wan-location to netsend a message to that location.
Now that we all use winxp and w2kserver (ad) the tool doesn't work anymore.
Now. de fakenetsend works but it is impossible to know which computers are at a specific location . We do know the names of the servers at the wan-locations. Is there a easy way to write this is c# ? (I just started with the very basics of c# so I might not understand everything)
Regards
Sander, the netherlands
|
|
|
|
|
I would appear that this conponent was a wrapper around the NET SEND command. Are you looking to send the message to everyone in a domain or everyone connected to a set of servers?
If so, then your class would just need to launch NET SEND with the appropriate parameters. This would send the message to everyone in the TESTDOM domain:
NET SEND * /domain:TEXTDOM This is my test message...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No, this is not the case.
It was a real class. It uses functions from an windows api.
If you like I can post the (vb6-)source (it's free of use I recall)
A little update: All wan locations are now memeber of the same domain so the netsend example you are suggesting doesn't work anymore. (the locations are now sites in ad)
Regards
|
|
|
|
|
It really doesn't matter how it's done. You can use the System.Diagnostics.Process class to do this programmatically, as we've discussed before in this forum:
string myDomainName = Environment.UserDomainName;
string theMessage = "This is a test.";
Process.Start("net.exe", string.Format("send * /domain:{0} {1}",
myDomainName, theMessage)); If you want a "better" way, you can encapsulate the NetMessageBufferSend API using P/Invoke:
public sealed class NetSend
{
public NetSend() {}
public Send()
{
if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
throw new NotSupportException();
}
[DllImport("netapi32.dll", CharSet=CharSet.Unicode)]
private static extern uint NetMessageBufferSend(
string servername,
string msgalias,
string fromname,
byte[] msg,
uint msglen);
[DllImport("netapi32.dll")]
private static extern uint NetApiBufferAllocate(
uint byteCount,
out IntPtr ptr);
[DllImport("netapi32.dll")]
private static extern uint NetApiBufferFree(
IntPtr ptr);
} See the documentation for the NetMessageBufferSend API on MSDN[^] or you could try searching this forum of the CodeProject site for existing examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
I'm having a problem with the release version of my application. A debug version of the same code works without flaws, but the release version throws an unhandled exception.
I have searched my code for "#if (DEBUG) ... #endif"'s and "[conditional (DEBUG)]" functions and made sure that nothing vital lies within such areas (nothing there now but some WriteLine()s ).
Does anyone know of other differences between release and debug that could cause one but not the other to fail?
|
|
|
|
|
You create a new project configuration that contains debug information but without the conditional DEBUG Conditional Compilation Constant, then you can at least put down breakpoints and step through the code to see what might be causing the problem.
|
|
|
|
|
That didn't seem to make much difference - it still runs in debug without the DEBUG constant.
But I discovered another really weird issue. As explained before I get an unhandled exception when I execute the release .exe file, but if I run the the application in release mode inside Visual Studio(VS) I don't get the exception.
It seems that somehow VS has an influence on the release runtime. Also a fellow coworker experienced the same problem with another application, but with the debug .exe file.
Does VS set up some special runtime environment that prevents unhandled exceptions?
|
|
|
|
|
You might want to post what the exact exception was.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It is a TypeInitializationException with the inner exception NullReferenceException - and why it is thrown only in the release version run outside VS is my big mystery. If I run the debug .exe file outside VS it doesn't throw anything.
|
|
|
|
|
Question: if you have a multi-project solution, did you add project references or assembly references? If you use assembly references (for projects in your solution), that can be a big problem since your release build will use assemblies from your debug build (or vice versa). If you added a new type and did a release build, this type would not be in the debug build of your assembly.
So, remove your assembly references for projects in your solution. Then re-add them by right-clicking on your project, select Add Reference, then click on the Projects tab and select the right projects. This makes sure that everything is kept in sync and sets up build dependencies as well.
When you run the application, everything should work fine. If you maintain a build directory for other developers, make sure that you copy all of the assemblies from the same build configuration into that build directory.
We have a very large solution (I have about 60 projects in mine, being the build master), many of which are late-bound. Using these guidelines it's pretty easy to make sure everything is correct.
Also make sure that if you have late-bound assemblies (like for a plug-in style application) that you either keep the assembly version the same or update your app's .config file using assembly version redirection. You can find more about that by reading Redirecting Assembly Versions[^] in the .NET Framework SDK. We also do this for ours so we don't have to re-deploy every assembly with updates to our application.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you for the reply, but alas to no avail - all my references are added as you describe above.
The world of VS is a cruel place 
|
|
|
|
|
Heureka! - the bug has been found.
It was a Singleton issue.
I had a Singleton class like the following:
private static readonly IOServiceAgent instance = new IOServiceAgent();<br />
<br />
private IOServiceAgent(){}<br />
<br />
public static IOServiceAgent Instance<br />
{<br />
get<br />
{<br />
return instance;<br />
}<br />
}
Changed it to the following:
private static IOServiceAgent instance;<br />
<br />
private IOServiceAgent(){}<br />
<br />
public static IOServiceAgent Instance<br />
{<br />
get<br />
{<br />
if(instance == null)<br />
{<br />
instance = new IOServiceAgent();<br />
}<br />
<br />
return instance;<br />
}<br />
}
Somehow the first solution failed even though the property wasn't called prior to the exception throw.
Anyway thanks for the replys
-spif2001
|
|
|
|