I am new to office development so I have a question. I have a database where rtf files are stored in image filed. From my application I need to show this rtf document in word application. I think I have to use office application PIA's.
One solution would be to save this image filed (rtf document) in some temp directory but then I would not be able to delete this file becouse I would not know when the user would stop using it.
So is there a way I can open this image field (rtf file as System.Byte) in word application not saving it before on physical drive?
If this is only RTF, you could use System.Text.Encoding.ASCII or System.Text.Encoding.Unicode (depending on how the RTF is stored) to convert to byte array to text and assign it to the RichTextBox.Rtf property.
If you need to use Word instead, you'll have to save this to a temporary file. The only way to load a stream is with a structured storage document, which RTF isn't (only compound documents like Word Documents are). Since you would be using the Office PIAs, however, you'll have to create an instance of Word.Application. Since you have that reference, you can attach events to know when the application is closed, or even if a document is closed. In this event handler, you can delete the temporary file.
MyClass now has all the functions/procedures and variables of a normal thread class. I would like to do the same thing in C# but I can't inherit from system.threading.thread because it's sealed. I suspect there might be another approach to this but I can't find much on google. I guess I am not searching for the right things here. I guess I'm trying to do this the Delphi way when I should be doing them the C# way!!!
In C# threads are handled differently. You create an instance of System.Threading.Thread and pass ThreadStart delegate to the constructor. ThreadStart delegate represents a method that thread will run.
//Run code here
Thread myTread = new Thread(new ThreadStart(RunMe));
Does anyone know how to select a node in a TreeView, inside the application?
Just like a mouse click event on the node.
I have tryed the different combination of
theTreeView.SelectedNode = theTreeView.Nodes;
It does work (I use it for a few things) but you won't notice unless 1) your TreeView has the focus, or 2) if another control has the focus you must set TreeView.HideSelection to false (default is true), otherwise it is selected but you just won't see that it is.
The easiest way - albeit not a very well-designed way - is to cast the Form.MdiParent property to your MDI parent's Form-derivative class, then access the Form.Menu property and - through the provided properties - disable the MenuItem you want.
A good design would use a modular design pattern in such a way that services are provided to the MDI child forms allowing them easily access the menu, or use the MenuItem.Merge method to merge menus defined on the MSI children with the menu for the parent form. See Form.MergedMenu property for more information.
Using the latter methods allows client forms to provide menus to the parent that they want to use. This is VERY common for most MDI applications. Just open Microsoft Word. Look at the menus available. Now close just the document (leaving the application window open). Your options are greatly decreased (although this process uses the concepts of Active Document containers and servers, but the idea is the same).