|
Hello,
I have a TreeView in my application which I wish to disable once an action was taken. I am using the following line for doing so but the problem is that it also Disables my Scrollbar.
The Code:
treeView1.Enabled = false;
Is there anyway to have Scrollbar active while the TreeView is not selectable?
Thank you for your help.
Khoramdin
|
|
|
|
|
I think the following should work for you assuming that you have the referenced boolean value that indicates whether selections are allowed:
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
e.Cancel = (_treeDisabled);
}
|
|
|
|
|
|
The Microsoft help says:
Note: This event is new in the .NET Framework version 2.0.
Usually that means there isn't anything like it in 1.1
Still if you want to have your form only do something once then perhaps you should consider the form load event.
Hope that helps.
Ben
|
|
|
|
|
I guess that's what I need.
However I would like to see a graph of all the events fired when a form is loaded.
And the orders of those events
company, work and everything else @ netis
|
|
|
|
|
Here is what is in the Microsoft help file:
Application Startup and Shutdown Events
The Form and Control classes expose a set of events related to application startup and shutdown. When a Windows Forms application starts, the startup events of the main form are raised in the following order:
System.Windows.Forms.Control.HandleCreated
System.Windows.Forms.Control.BindingContextChanged
System.Windows.Forms.Form.Load
System.Windows.Forms.Control.VisibleChanged
System.Windows.Forms.Form.Activated
System.Windows.Forms.Form.Shown
When an application closes, the shutdown events of the main form are raised in the following order:
System.Windows.Forms.Form.Closing
System.Windows.Forms.Form.FormClosing
System.Windows.Forms.Form.Closed
System.Windows.Forms.Form.FormClosed
System.Windows.Forms.Form.Deactivate
The ApplicationExit event of the Application class is raised after the shutdown events of the main form.
Ben
|
|
|
|
|
Thanks that is most helpfull. Do you have a link for that?
As I see this is for .Net > 2.0
company, work and everything else @ netis
|
|
|
|
|
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxmancli/html/e81db09b-4453-437f-b78a-62d7cd5c9829.htm
Ben
|
|
|
|
|
Is there someone who could help me with this please
What I want to do is that:
1) Execute the server on my machine.
2) Through that server, initialize/execute the clients(.exe) on the client machines(known machine-names/IP addresses).
3) Clients will then start communication with the server.
I actually need help with that 2nd step.
PsExec looks to be interesting, but I want that step 2 to be done by my server.
---------------------------------------------------------------------------------------------
Like for example when I do something like this:
Process proc = new Process();
ProcessStartInfo info = new ProcessStartInfo("C:\\client.exe");
proc.Start();
The above will execute the client.exe on my C drive.
But I want to execute this file on other machines residing on the same network (LAN).
Thanks.
Sarfraz.
-- modified at 11:27 Tuesday 27th February, 2007
Sarfraz
|
|
|
|
|
|
This looks like to be some thing that I actually need:
ConnectionOptions objConnectionOptions = new ConnectionOptions();
objConnectionOptions.Impersonation = ImpersonationLevel.Impersonate;
objConnectionOptions.EnablePrivileges = true;
objConnectionOptions.Username = strUserName;
objConnectionOptions.Password = strPassword;
ManagementScope objManagementScope = new ManagementScope(@"\\remote-machine-name\ROOT\CIMV2", objConnectionOptions);
objManagementScope.Connect();
ManagementClass processClassFinal = new ManagementClass(objManagementScope, new ManagementPath("Win32_Process"), null);
ManagementBaseObject inParamsFinal = processClassFinal.GetMethodParameters("Create");
inParamsFinal["CommandLine"] = @"\\remote-machine-name\some-directory\someProgram.exe";
ManagementBaseObject outParamsFinal = processClassFinal.InvokeMethod("Create", inParamsFinal, null);
But for some reason it does not work and I don't know why???????
outParamsFinal["processId"] returns null, instead of a valid processId.
Is there any one who could help me in that..............
Thanks
Sarfraz
|
|
|
|
|
What is the best solution for store html/javascripts scripts?
I want to store alot of html/javascripts codes as a ? maybe array or db or?, what is the best solution for that? I cant use sql unless, I can build it in the program.
If it's possible, then I dont want to do this every line:
html += "<html>\n"
+"<head>\n"
+"<meta........
It most be easy!
Thanks!
PS: It would be great with some code examples because I am neally started on C#/C Sharp
|
|
|
|
|
You could store the html/javascript in resource files.
only two letters away from being an asset
|
|
|
|
|
Thanks for the quick answer!
I have tried that but then a have to call every single code as
"string code = Resource1.String1.ToString();" or is there i better solution for doing that?
Thanks
|
|
|
|
|
Are you saying you want to store each html tag as a different resource then concatentate them together to form a page?
only two letters away from being an asset
|
|
|
|
|
No thats what i dont want to but i very new in C#, so how can i do it more easy?
|
|
|
|
|
Create a complete html or javascript file and store it as a resource.
only two letters away from being an asset
|
|
|
|
|
Sorry i ask agian but how do i load it into the program?
|
|
|
|
|
|
Thanks !
|
|
|
|
|
Files or file segments can also be stored to memo/text fields and assembled on the fly. Generally you would not want to deploy individual JavaScript routines individually, so unless you are archiving them for research, I don't see what the point of separating them would be. What we need to know is what purpose you have. Your design should be driven by that purpose (which indicates available resources, limitations, etc.). The approach to storage and retrieval otherwise is practically unlimited. Given a purpose and working environment, you always want to store as much together as possible. You should not be writing a head tag, meta tags, and finally a head conclusion tag. Write them all together unless there is a purpose that is served by separating them. Even then, separation can be avoided. Build the whole head section for instance with an author field content in it by replacing an author field token in the whole head section. Write the whole result of such a process to a file, and it can be displayed as a page.
A principle of development is to minimize operations. It looks like you are multiplying operations unnecessarily here.
|
|
|
|
|
sorry if i missed to say it... but i doesn't use the html/javascripts in the program.
It just for archive them in the app
|
|
|
|
|
That's fine, but the reason that I stipulated "for research" is this...
If you have a page which is downloaded by a user agent, or if you have many pages which are downloaded by user agents... it would be a very inefficient thing to do to try to logically predetermine what JavaScript functions are required in the particular page, and serve those out with the page.
Why?
If you have 4 scripts, W, X, Y, and Z, and if page 1 uses W and Z, page 2 uses Y and Z... and so many further pages call any possible further combination of the other scripts, the proper way to develop your site is to write the scripts in a separate JavaScript file linked to your pages. This way your scripts only cross bandwidth once. Each additional page request merely checks if the JavaScript resouce file is still valid.
Doing this so also eliminates your logical and assembly processes.
Furthermore, with today's security concerns, it is an ever worse idea to use JavaScript or ActiveX any more... and I should warn you that if you use either, the chances are very great that anyone running proper security *can never view your material*.
Personally, I've run the gamut of JavaScript implementations over many years, and have reverted to using JavaScript for one thing only -- copying code snippets from text fields in online documentation. If you use FireFox intelligently, you'll notice that most users will have JavaScript disabled, and will make a decision whether the functionality or material of your site justifies allowing your site to act on their system. If *I* am that visitor, I will ask myself why you built the functionality with JavaScript... find you don't have a good enough reason for me to disable my security... and move on.
|
|
|
|
|
I'm trying to make a small console application to grab some Access databases off a network drive and store them in a SQL server database (for archiving/backup). The problem is, if any user has a database open in Access on their computer I get an IOException about how it can't access the file because another process is already using it. Thats fine, but all I want to do is read the bytes, not change anything. I can open explorer, navigate to the directory, and manually copy the .mdb file when its open, but my program won't open it?
I have tried it like this:
<br />
bu.File = File.ReadAllBytes(dr["path"].ToString());<br />
Where bu is an instance of my class that stores backup information, bu.File is a byte[], and dr is a DataRow containing connection information.
and more explicitly like this:
<br />
FileStream fs = new FileStream(dr["path"].ToString(), FileMode.Open, FileAccess.Read);<br />
BinaryReader br = new BinaryReader(fs);<br />
bu.File = br.ReadBytes(Convert.ToInt32(fs.Length));<br />
Any suggestions?
|
|
|
|
|
Would it be possible to copy the file to a temporary location and read it from there rather than the locked file?
only two letters away from being an asset
|
|
|
|