I thought that Calendar was a control! Well it seems then that I should be able to get this done using C#. I'll have a look on those articles you mentioned. I am currently reading "Essential COM" by Dan Box to learn about COM.
Thanks again for all the info, I'll do some reasing and see what I can brew
A few days ago I invested in Visual C#.NET with a purpose of learning how to build Office add-ins. I purchased the standard, educational edition, not the professional edition which includes VB and C++.
The edition of Visual Studio I have does not have the add-in wizard that the professional edition has.
With that in mind, how can I create my add-ins?
In other words, how do I build add-ins to office without the wizard using the standard edition of Visual C#?
Thanks Michael, the link looks promising, I am looking into it. The Wizard I am talking about is called "Shared Add-in" and can be found by selecting "New Projects" from the file menu, then "Other Projects" and "Extensibility Projects".
All the documentation that I have on add-ins points to this wizard, which I don't have, hence my problem.
I wrote an application that writes to disk a certain excel document from sql database, then opens it edit.
After user finished editing the document in Excel, the application asks in a dialog if user wants to update the changes to DB. If yes, updates the file in the database.
The problem is, that after Excel window is closed and file updated to db, the Excel process is still running. It can be seen in Process Manager,
and causes incorrect behaviour of new Excel windows. After opening 50 documents, there are 50 processes. That causes serious errors in Excel, up to "OLE library error", which can be cured so far by re-installing Office.
The question is: How to kill Excel properly?
Here is the code:
private void OpenExcel(string filename)
System.Diagnostics.Process myproc = new System.Diagnostics.Process();
myproc.EnableRaisingEvents = true;
//a special exitbox is assigned to each document
ExitBox windowAfterExit = new ExitBox(filename,this,myproc);
// at a moment we can work with one document only
publicclass ExitBox : System.Windows.Forms.Form
publicvoid Excel_Exited(object sender,EventArgs e)
//Excel exited, so show this windowthis.Visible = true;
//tried this to kill Excel
//all necessary changes are submitted to Db, so delete the file
//close the form(hope it disposes all resources too :) ) this.Close();
I am looking for a way to get the equivalent functionality of WIN32's DrawText() API function when used with DT_CALCRECT and DT_WORDBREAK.
I am writing a control that will resize itself vertically on a form when its Text property is changed. I have tried using the Graphics.MeasureString() method and I cannot figure out how to get it to return the height of a string to a fixed width.
See the StringFormat class (the defaults should do, but you can create your own) and the Graphics.DrawString method, which you can use in the OnPaint method override (always override methods instead of handling events in derived classes, but make sure to call the base class's method in most cases):
protectedoverridevoid OnPaint(PaintEventArgs e)
RectangleF rectF = GetRectFBoundsForControl(); // Made-up method to// get the bounds in which text can be drawn.
e.Graphics.DrawString("Some multi-line text",
StringFormat.GenericDefault); // Or create your own
Otherwise, you can always just P/Invoke DrawText, define the DT_CALCRECT and DT_WORDBREAK constants (or enum values) based on the preproc def values, and call the method using the control's HDC, which you can get during the Paint event (override OnPaint when deriving from Control instead):
ShaneStump wrote: I want it to return the # height of the string if wrapping occurs (if the string requres 5 lines, I want the returned height to be for the 5 lines). I am probably NOT using the right method.
Hmm, the MeasureString method is overloaded, and if you know the maximum width in pixels that your control will represent (I don't know if you will know this?) then you can make a call as such which will take into account wrapping.
private SizeF MyMeasureMethod(PaintEventArgs e)
string s = "Nick";
Font f = new Font("Arial", 12);
int width = 300;
SizeF strSize = new SizeF();
strSize = e.Graphics.MeasureString(s, f, width);
How does one programmatically "select" a node in a TreeView.
IE: the user clicks a button which spawns a child process, the output of which is displayed in a TextBox. Each time the user clicks that button, a new process is kicked off and I attach a new node to the TreeView to represent said process. If the user clicks on any given node, that node's associated process output TextBox is brought to the foreground - whre you can watch the output.
Adding the node to the TreeView is straightforward, but hilighting it or "selecting" it programmatically is not so easy.
Active and Selected are two completely different things. Active just means that the node has the focus, such as what it gains when you right-click the node. Selected means that the node has been left-clicked at some point. To select a node programmatically, just use the following:
After doing this - indeed the "selected" image appears to the left of the tree node (from the ImageList index used when creating the node) but, the actual text of the node is not "highlighted. IE: the folder opens, but the folder name is not highlighted.
This is even more obvious when working with a ListView. I've selected a particular ListViewItem, but no rectangular, reverse color block around the text of the item appears onscreen.
Maybe I am doing something wrong - or missing something? Without the highlighted text, its not really obvious which element has been selected.
Out of curiousity, does the rectangular marquee (the dotted lines) around the text appear? If so, the TreeView no longer seems to have the focus. Set TreeView.HideSelection to false and see if the rectangular selection region is at least gray (or whatever the default system color for inactive selected text is).