<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
>

<channel>
	<title>ITauthor &#187; C#/Visual Studio/.NET</title>
	<atom:link href="http://www.itauthor.com/category/cvisual-studionet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.itauthor.com</link>
	<description>Stuff about technical writing and software</description>
	<lastBuildDate>Sat, 07 Jan 2012 12:34:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<!-- podcast_generator="Blubrry PowerPress/2.0.4" -->
	<itunes:summary>Talking about technical writing, software and technology in general. The ITauthor Podcast is an advert-free, irregularly published show by technical writers for technical writers or anyone interested in software documentation or IT generally.</itunes:summary>
	<itunes:author>Alistair Christie - ITauthor.com</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.itauthor.com/images/ITauthor-PhotoLogo-300px.jpg" />
	<itunes:owner>
		<itunes:name>Alistair Christie - ITauthor.com</itunes:name>
		<itunes:email>comments@itauthor.com</itunes:email>
	</itunes:owner>
	<managingEditor>comments@itauthor.com (Alistair Christie - ITauthor.com)</managingEditor>
	<copyright>2006-2009</copyright>
	<itunes:subtitle>Talking about technical writing, software and technology in general.</itunes:subtitle>
	<itunes:keywords>itauthor, alistair christie, technology, writing, documentation</itunes:keywords>
	<image>
		<title>ITauthor &#187; C#/Visual Studio/.NET</title>
		<url>http://www.itauthor.com/images/ITauthor-PhotoLogo-144px.jpg</url>
		<link>http://www.itauthor.com/category/cvisual-studionet/</link>
	</image>
	<itunes:category text="Technology">
		<itunes:category text="Software How-To" />
		<itunes:category text="Tech News" />
		<itunes:category text="Podcasting" />
	</itunes:category>
		<item>
		<title>Accessing one form&#8217;s controls from another form</title>
		<link>http://www.itauthor.com/2007/09/16/accessing-one-forms-controls-from-another-form/</link>
		<comments>http://www.itauthor.com/2007/09/16/accessing-one-forms-controls-from-another-form/#comments</comments>
		<pubDate>Sun, 16 Sep 2007 21:39:00 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>
		<category><![CDATA[View all]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/2007/09/16/accessing-one-forms-controls-from-another-form/</guid>
		<description><![CDATA[Here's the situation: In a .NET appication I have a form containing several controls (lets call this MainForm). I want to allow the user to change many of the properties of this form, such as the background colour, the labels, the font, etc. To do this I have a separate form (PropertiesForm). The question is, [...]]]></description>
			<content:encoded><![CDATA[<p>Here's the situation:</p>
<p>In a .NET appication I have a form containing several controls (lets call this MainForm). I want to allow the user to change many of the properties of this form, such as the background colour, the labels, the font, etc. To do this I have a separate form (PropertiesForm). The question is, how do I access the properties of the MainForm controls from within PropertiesForm.</p>
<p>You might think that it was a simple case of making the MainForm class and/or the control objects declared within MainForm public rather than private. But this isn't enough. Instead you need to declare an internal (or public) variable&nbsp;whose type is the name of the class you want to access (in my case MainForm)&nbsp;and then when you open the new form from MainForm set&nbsp;that variable&nbsp;to the&nbsp;MainForm form. That sounds complicated, but it's easier to show it than to explain it in writing.</p>
<p>&nbsp;</p>
<p>Here's part of the PropertiesForm code from a file called <strong>Form2.cs</strong>:</p>
<p><font face="Courier New" color="#800000" size="1">namespace MyCsharpProgram<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public partial class&nbsp;PropertiesForm : Form<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//Declare a variable for the main form:</font></font></p>
<p><font face="Courier New" color="#800000" size="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;internal MainForm ParentForm;</font></p>
<p><font face="Courier New" color="#800000" size="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></p>
<p><font size="1"><font face="Courier New" color="#800000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private void buttonUpdateForm_Click(object sender, EventArgs e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000">//Change the text of the exit button:</font></font></font></p>
<p><font face="Courier New" color="#800000" size="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ParentForm.buttonExit.Text = sExitButtonText;</font></p>
<p><font size="1"><font face="Courier New" color="#800000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </font></font></p>
<p><font size="1"><font face="Courier New" color="#800000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </font></font>
<p><font size="1"><font face="Courier New" color="#800000">} </font></font>
<p>In the above code, clicking the "buttonUpdateForm" button on the PropertiesForm form changes the text of a button called buttonExit on the parent form.
<p>Here's part of the MainForm code from a file called <strong>Form1.cs</strong>
<p><font size="1"><font face="Courier New" color="#800000">namespace MyCsharpProgram<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public partial class MainForm : Form<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ </font></font></p>
<p><font size="1"><font face="Courier New" color="#800000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... </font></font>
<p><font size="1"><font face="Courier New" color="#800000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private void linkLabelProperties_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertiesForm PropertiesForm = new PropertiesForm();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertiesForm.ParentForm = this;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PropertiesForm.ShowDialog();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </font></font></p>
<p><font size="1"><font face="Courier New" color="#800000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... </font></font>
<p><font size="1"><font face="Courier New" color="#800000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} </font></font>
<p><font size="1"><font face="Courier New" color="#800000">} </font></font>
<p>Here, in MainForm, I have an event handler for a link label called linkLabelProperties. When this link label is clicked we create a new instance of PropertiesForm and we set the object called ParentForm to this form (i.e. MainForm). We then display the form.
<p>What we're doing here is passing a reference&nbsp;to the MainForm&nbsp;form into the PropertiesForm form, so that you can access MainForm objects from PropertiesForm.</p>
<p>The&nbsp;<strong>Form1.Designer.cs</strong> file contains the definition of the buttonExit button, which is declared as internal, rather than private, so that we can access it from another class:</p>
<p>
<p><font face="Courier New" color="#800000" size="1">namespace VocabBuilder<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public partial class VocabBuilderForm<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</font></p>
<p><font face="Courier New" color="#800000" size="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... </font>
<p><font face="Courier New" color="#800000" size="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;internal System.Windows.Forms.Button buttonExit;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... </font></p>
<p><font face="Courier New" color="#800000" size="1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />}</font></p>
<p>I should add that if you're writing serious code this is <em>not</em> the correct way to do this. How you should do it is to use delegates. This makes the classes and methods much more independent and&nbsp;makes it much easier to&nbsp;maintain them in a large body of code, and to reuse classes&nbsp;in other programs. &nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2007/09/16/accessing-one-forms-controls-from-another-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing to a log file in C#</title>
		<link>http://www.itauthor.com/2007/08/21/writing-to-a-log-file-in-c/</link>
		<comments>http://www.itauthor.com/2007/08/21/writing-to-a-log-file-in-c/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 15:48:24 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>
		<category><![CDATA[View all]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/2007/08/21/writing-to-a-log-file-in-c/</guid>
		<description><![CDATA[Here's a chunk of code that will write values to a log file. If the file doesn't exist, it creates it, otherwise it just appends to the existing file. You need to add "using System.IO;" at the top of your code, if it's not already there. string strLogText = "Some details you want to log."; [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a chunk of code that will write values to a log file. If the file doesn't exist, it creates it, otherwise it just appends to the existing file. You need to add "using System.IO;" at the top of your code, if it's not already there.</p>
<p><font face="Courier New" size="2">string strLogText = "Some details you want to log.";</p>
<p>// Create a writer and open the file:<br />StreamWriter log;</p>
<p>if (!File.Exists("logfile.txt"))<br />{<br />&nbsp;&nbsp;log = new StreamWriter("logfile.txt");<br />}<br />else<br />{<br />&nbsp;&nbsp;log = File.AppendText("logfile.txt");<br />} </p>
<p>// Write to the file:<br />log.WriteLine(DateTime.Now);<br />log.WriteLine(strLogText);<br />log.WriteLine(); </p>
<p>// Close the stream:<br />log.Close();</font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2007/08/21/writing-to-a-log-file-in-c/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Variable-length arrays in C#</title>
		<link>http://www.itauthor.com/2007/08/19/variable-length-arrays-in-c/</link>
		<comments>http://www.itauthor.com/2007/08/19/variable-length-arrays-in-c/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 10:57:22 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>
		<category><![CDATA[View all]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/2007/08/19/variable-length-arrays-in-c/</guid>
		<description><![CDATA[Because I'm most familiar with Perl programming, whenever it's been a while since I've done any C# coding I often spend time re-remembering how to do variable-length arrays. In C#, if you want to use an array you've got to say up front how many elements it's going to contain. If, later in the code, [...]]]></description>
			<content:encoded><![CDATA[<p>Because I'm most familiar with Perl programming, whenever it's been a while since I've done any C# coding I often spend time re-remembering how to do variable-length arrays. In C#, if you want to use an array you've got to say up front how many elements it's going to contain. If, later in the code, you try to assign it more items than you said it would contain, you get an error.</p>
<p>But often you don't know how many items an array is going to need. It may vary every time you run the program. In this situation, you need to use C#'s ArrayList type. To use this you need to add:</p>
<p><strong>using System.Collections;</strong></p>
<p>up top of your code. You can then create a new ArrayList instance like this:</p>
<p><strong>private ArrayList ResultsArrayList = new ArrayList();</strong></p>
<p>Notice, you didn't have to give an elements limit to the list.</p>
<p>You can then add stuff to the ArrayList:</p>
<p><strong>ResultsArrayList.Add(ResultRecord);</strong></p>
<p>In this example, from code I've just been writing, ResultRecord is actually an array of field values. So here I'm creating a list of results, each of which contains a set of result values. I use this to capture search results where I know there's a fixed set of result fields for each search result (so I can use a simple array for each hit), but I don't know how many hits are going to come back from the search (so I need to use an ArrayList for the results set).</p>
<p>In the following code, to output my ArrayList of Arrays to the console, I do a <strong>for</strong> loop through each item in the ArrayList and within that (for each individual search result) I do a <strong>foreach</strong> loop to print out each item (or field) of data for that hit:</p>
<p><strong>for (int i=0; i &lt; ResultsArrayList.Count; i++)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine("HIT {0}:", i);<br />&nbsp;&nbsp;&nbsp;&nbsp;// Note: ResultsArrayList[i] needs to be cast as a string[] before it can be assigned:<br />&nbsp;&nbsp;&nbsp;&nbsp;string[] newarray = (string[])ResultsArrayList[i];<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach (string str in newarray)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine("ITEM: {0}", str);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}</strong>
<p>The trouble with C# is that it's really difficult to Google for it. Google for "C#" and you get any page containing "C"! I've I've really got to try and remember about ArrayLists for when I do more C# stuff in 6 months or a year, to save myself trawling through pages and pages of stuff on arrays - none of which start with a simple redirection like: "If you don't know how many elements your array is going to need, use an ArrayList rather than an array."</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2007/08/19/variable-length-arrays-in-c/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Case-insensitive substring search (C#)</title>
		<link>http://www.itauthor.com/2007/08/18/case-insensitive-substring-search-c/</link>
		<comments>http://www.itauthor.com/2007/08/18/case-insensitive-substring-search-c/#comments</comments>
		<pubDate>Sat, 18 Aug 2007 12:08:24 +0000</pubDate>
		<dc:creator>ac</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>
		<category><![CDATA[View all]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/2007/08/18/case-insensitive-substring-search-c/</guid>
		<description><![CDATA[Problem: You want to do an IndexOf search to check whether searchString occurs in chunkOfText. You want the match to be case-insensitive, but you don't want to have to convert both stings to lower case or upper case before doing the comparison because it slows things down. Answer (in .NET): Use the CompareInfo class from [...]]]></description>
			<content:encoded><![CDATA[<h3>Problem: </h3>
<p>You want to do an IndexOf search to check whether searchString occurs in chunkOfText. You want the match to be case-insensitive, but you don't want to have to convert both stings to lower case or upper case before doing the comparison because it slows things down.</p>
<h3>Answer (in .NET):</h3>
<p>Use the <strong>CompareInfo</strong> class from <strong>System.Globalization</strong>.</p>
<h3>How to do it:</h3>
<p>Add <strong>using System.Globalization;</strong> at the top of your code.</p>
<p>Then you can do something like</p>
<p><strong>int searchResultInt = CultureInfo.CurrentUICulture.CompareInfo.IndexOf(chunkOfText, searchString, CompareOptions.IgnoreCase);</strong></p>
<p>Where <strong>chunkOfText </strong>is the string you want to search through and <strong>searchString </strong>is the string you're looking for - that is, the substring. As with a normal IndexOf, this returns -1 if there's no match, or the index of the first character if a match is found.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2007/08/18/case-insensitive-substring-search-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Matching braces</title>
		<link>http://www.itauthor.com/2006/02/26/matching-braces/</link>
		<comments>http://www.itauthor.com/2006/02/26/matching-braces/#comments</comments>
		<pubDate>Sun, 26 Feb 2006 12:49:46 +0000</pubDate>
		<dc:creator>alistair at home</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/?p=185</guid>
		<description><![CDATA[Quick note to myself, because I always forget how to do this in Visual Studio. To match a brace, place the cursor just before or after it and press Ctrl + ] To select a block marked by braces, place the cursor just before or after it and press Ctrl + } It would be [...]]]></description>
			<content:encoded><![CDATA[<p>Quick note to myself, because I always forget how to do this in Visual Studio.</p>
<p>To match a brace, place the cursor just before or after it and press Ctrl + ]</p>
<p>To select a block marked by braces, place the cursor just before or after it and press Ctrl + }</p>
<p>It would be nice if Visual Studio automatically highlighted the matching brace when you placed the cursor beside a brace - like UltraEdit does - but you have to remember the shortcut.</p>
<p>Now to add this to my bookmarks on delicious...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2006/02/26/matching-braces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RegexDesigner</title>
		<link>http://www.itauthor.com/2006/02/25/regexdesigner/</link>
		<comments>http://www.itauthor.com/2006/02/25/regexdesigner/#comments</comments>
		<pubDate>Sat, 25 Feb 2006 09:27:13 +0000</pubDate>
		<dc:creator>alistair at home</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/?p=184</guid>
		<description><![CDATA[I came across this really useful tool for trying out regular expressions for Visual Studio: This allows you to write your regular expression, input the text you're going to run it against and then do a match or a replace and see what the results are. Once you're happy that your regular expression matches/replaces what [...]]]></description>
			<content:encoded><![CDATA[<p>I came across this really useful tool for trying out regular expressions for Visual Studio:</p>
<p><img alt="RegexDesigner.jpg" src="http://www.itauthor.com/notes/archives/RegexDesigner.jpg" width="560" height="340" /></p>
<p>This allows you to write your regular expression, input the text you're going to run it against and then do a match or a replace and see what the results are.</p>
<p>Once you're happy that your regular expression matches/replaces what it's supposed to you can generate the code (in either VB or C#) and just copy it into Visual Studio.</p>
<p>You can download this .NET app from <a href="http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=01e0dfb7-0182-45cd-94f7-2ed2df2504a9">www.gotdotnet.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2006/02/25/regexdesigner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding menu items in Visual Studio &#8211; a solution</title>
		<link>http://www.itauthor.com/2004/01/26/adding-menu-items-in-visual-studio-a-solution/</link>
		<comments>http://www.itauthor.com/2004/01/26/adding-menu-items-in-visual-studio-a-solution/#comments</comments>
		<pubDate>Mon, 26 Jan 2004 07:53:40 +0000</pubDate>
		<dc:creator>alistair at work</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/?p=47</guid>
		<description><![CDATA[I've now finished writing up a description of how to use Phil Wright's Magic Library GUI classes for .NET to add icons to items in a menu. You can find my article at:
<a href="http://www.itauthor.com/VisualStudio/VisualStudio-Csharp/menucontrols.html">www.itauthor.com/VisualStudio/VisualStudio-Csharp/menucontrols.html</a>]]></description>
			<content:encoded><![CDATA[<p>I've now finished writing up a description of how to use Phil Wright's Magic Library GUI classes for .NET to add icons to items in a menu. You can find my article at:<br />
<a href="http://www.itauthor.com/VisualStudio/VisualStudio-Csharp/menucontrols.html">www.itauthor.com/VisualStudio/VisualStudio-Csharp/menucontrols.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2004/01/26/adding-menu-items-in-visual-studio-a-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Formatter and NDoc</title>
		<link>http://www.itauthor.com/2004/01/25/c-formatter-and-ndoc/</link>
		<comments>http://www.itauthor.com/2004/01/25/c-formatter-and-ndoc/#comments</comments>
		<pubDate>Sun, 25 Jan 2004 06:29:20 +0000</pubDate>
		<dc:creator>alistair at home</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/?p=46</guid>
		<description><![CDATA[NDoc and the C# to HTML convertor:
<ul><li>NDoc - a great way to turn the XML produced by ///-type comments in C# code into professional-looking Help.</li><li>The C# to HTML convertor - a web-based program that takes C# code, copied into a text box on a web form, and turns it into a colour-formatted version in HTML.</li></ul>]]></description>
			<content:encoded><![CDATA[<p>The internet really is a wonderful thing. How else could I have found out about NDoc? </p>
<p>What's NDoc? Well, it's this fabulous tool for turning the XML file produced by Visual Studio from ///-type comments in C# code into professional-looking documentation. </p>
<p>I'm in the middle of documenting how to add menu control containing icons to a C# application, using Phil Wright's Magic Libary 1.7 user interface class library for .NET. As part of the page I'm writing (<a href="http://www.itauthor.com/VisualStudio/VisualStudio-Csharp/menucontrols.html">www.itauthor.com/VisualStudio/VisualStudio-Csharp/menucontrols.html</a>), I wanted to include a listing of the simple example program I wrote. There must be something out there that converts C# code to HTML and does it as nicely as perltidy &ndash; see my previous entries on this (<a href="http://www.itauthor.com/notes/archives/000012.html">21 November</a> and <a href="http://www.itauthor.com/notes/archives/000013.html ">22 November</a>).</p>
<p>In fact it took a lot more searching than I thought it would, but my searches eventually led to Jean-Claude Manoli's web site and the C# formatter he wrote "to learn how to use the .NET Framework's  regular expressions" (<a href="http://www.manoli.net/csharpformat/">www.manoli.net/csharpformat/</a>). Seems like a lot of work to go to just to learn regexps, but, hey, I'm not complaining because the end result is a cracking good C# code to HTML convertor. Here's <a href="http://www.itauthor.com/VisualStudio/VisualStudio-Csharp/menucontrols-app-source.html">an example</a> of what it outputs.</p>
<p>My only disappointment about it is that Jean-Claude didn't provide a downloadable application version of the convertor. He did, however, provide his C# source code. The only trouble with that is that you have to know what to do with it and (guess what &ndash; I'll try not to get on my high horse here, promise!) he didn't supply any documentation to go with it to tell you what to do with the source.</p>
<p>Well, actually, that last sentence isn't true. Jean-Claude has commented his code, so there is documentation. And that brings me to NDoc.</p>
<p>Jean-Claude mentions on his site some of the projects he's been working on. One of them is NDoc: an open-source application that makes it easy to "create great looking C# code documentation". That caught my eye, so I followed the link to more information about NDoc and these links to other articles:</p>
<ul>
<li><a href="http://www.squiffler.com/squiffler/article.aspx?id=1">www.squiffler.com/squiffler/article.aspx?id=1</a><br />An article by Ollie Cornes that introduces the topic of using /// comments to produce XML source for documentation. It describes using Visual Studio's inbuilt tool for outputting web page help from the XML and then touches on NDoc. This article is a good starting point. However, it's not been designed to print out in IE (though it prints okay in Mozilla). I've produced a <a href="http://www.itauthor.com/notes/Documenting-Csharp.html">printable version of Ollie's article</a>.</p>
<li><a href="http://www.codeproject.com/csharp/CSharpCommentingandDocs.asp">www.codeproject.com/csharp/CSharpCommentingandDocs.asp</a><br />A short article by Patrick Long, which appears on the very excellent Code Project web site. This covers some of the same ground as the previous article, but more briefly. It gives a bit more detail about NDoc.
<li><a href="http://www.ondotnet.com/pub/a/dotnet/2002/12/09/ndoc.html">www.ondotnet.com/pub/a/dotnet/2002/12/09/ndoc.html</a><br />This O'Reilly Network article ought to enthuse you to take a look at NDoc. The author, Shawn Van Ness, is a big fan of NDoc and uses it on all his .NET projects. He concludes: "With each new project I work on, I grow continuously more impressed with the flexibility and versatility of NDoc. It's saved me hundreds of hours of tedious labor engineering my own MSDN-style documentation solution, and it looks good doing it!"</ul>
<p>Having looked at what it does, I totally agree that NDoc is a must-have application for any .NET developer who's interested in making his/her code accessible to others. There are two very smart things going on here. One of them, of course, is NDoc, which is a very clever bit of work. The best things about it are that a) it's free, and b) it works like a dream. The other smart thing is Microsoft's comments-to-XML-file functionality that makes it all possible. The important thing about so-called self-documenting software is that the end result is only as good as the quality of the comments in the code. Generally (and this <i>is</i> a generalisation) developers are very resistant to the idea of writing in sentences, never mind standard English. To me it seems strange how developers can get the spelling of weirdly named programming commands and functions correct, and they can use the correct syntax, and yet, despite their mastery of a programming language, they often have only a rudimentary grasp of the English language &ndash; and I'm talking about English-speaking programmers here.</p>
<p>Anyway, NDoc is a great piece of work and I heartily recommend it to you. If you want to try it out, download the source code for Jean-Claude Manoli's C# formatter from <a href="http://www.manoli.net/csharpformat/">www.manoli.net/csharpformat/</a>, then download NDoc from SourceForge (<a href="http://ndoc.sourceforge.net/download.html">http://ndoc.sourceforge.net/download.html</a> &ndash; I chose the <a href="http://prdownloads.sourceforge.net/ndoc/NDocSetup.Exe?download">web-based .exe downloader</a> for NDoc 1.2). Run the installer. It's a quick install and you don't have to restart the computer.</p>
<p>You will probably also want to download <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/htmlhelp/html/hwmscextendingnethelp.asp">the Visual Studio .NET Help Integration Kit</a> from the MSDN web site (if this link doesn't work, go to msdn.microsoft.com/library and search for "VSHIK"). It's is a 6.5MB download, but you need it to produce Miscrosoft Help 2 help from NDoc. (NDoc's default output is MSDN-style help.) Then open Jean-Claude Manoli's C# formatter solution in Visual Studio .NET. Right click on the project in the Solution Explorer and in the left pane of the Property Pages dialog box, click Configuration Properties. Notice that in the Outputs section, there's a property called XML Documentation File. This is set to CSharpFormat.xml. This is the XML documentation file that Visual Studio will produce from the code (including the comment lines beginning ///). Build the project and browse to the project directory in Windows Explorer. Open up CSharpFormat.xml in a web browser. You'll see that Visual Studio has done some clever stuff. It's not just a dump of all the /// lines.</p>
<p>Next, start up NDoc (e.g. \NDoc\bin\.net-1.1\NDocGui.exe). Click Add. In the dialog box, use the browse buttons and Open dialog boxes to add \obj\debug\CSharpFormat.dll as the Assembly Filename, and \CSharpFormat.xml as the XML Doc Filename. Click OK. In the NDoc window, click the Namespace Summaries button. Add a description of the Manoli.Utils.CSharpFormat namespace. Click OK.</p>
<p>Click the Build Documentation button:</p>
<p><a href="http://www.itauthor.com/notes/images/NDoc-main-window.gif"><img alt="NDoc-main-window.gif" src="http://www.itauthor.com/notes/images/NDoc-main-window.gif" width="504" height="664" border="0" /></a></p>
<p>On my machine it takes less than 10 seconds to build the documentation for this class library. Click the View button. The finished product looks like this.</p>
<p><a href="http://www.itauthor.com/notes/images/NDoc-example-CSharpFormat.gif"><img alt="NDoc-example-CSharpFormat.gif" src="http://www.itauthor.com/notes/images/NDoc-example-CSharpFormat.gif" width="786" height="507" border="0" /></a></p>
<p>You can choose to output in other formats (e.g. HTML Help or as web pages) if you prefer. I'd say that was bloody marvellous. Hats off to everybody on the NDoc team!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2004/01/25/c-formatter-and-ndoc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why is it so difficult to add menu item icons in Visual Studio</title>
		<link>http://www.itauthor.com/2004/01/17/why-is-it-so-difficult-to-add-menu-item-icons-in-visual-studio/</link>
		<comments>http://www.itauthor.com/2004/01/17/why-is-it-so-difficult-to-add-menu-item-icons-in-visual-studio/#comments</comments>
		<pubDate>Sat, 17 Jan 2004 09:40:38 +0000</pubDate>
		<dc:creator>alistair at home</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/?p=45</guid>
		<description><![CDATA[Microsoft spent hundreds of person hours writing Visual Studio for .NET. How come they didn't include an easy way to add icons to menu items like File > Open?]]></description>
			<content:encoded><![CDATA[<p>I may be missing something, but I find it hard to credit that Visual Studio doesn't include an easy way to add icons to menu items. I'm playing around with C#, creating Windows apps and all I want to do is have the standard icons beside the File &gt; New and File &gt; Open menu items. Creating the menu bar and its contents is very easy, but there seems to be no easy way to add icons, and MSDN is unhelpful on the solution.</p>
<p>I found a potentially helpful article at:<br />
<a href="http://www.csharphelp.com/archives2/archive416.html">http://www.csharphelp.com/archives2/archive416.html</a><br />
but it's only helpful if you're an experience C# programmer &ndash; it's way over my head!</p>
<p>I'd have thought that so many Windows app use these standard menu items, Visual Studio would add the icons, standard shortcuts and Alt key combinations by default. It's such a huge, complex program, I'm amazed they didn't think about adding an easy method of adding menu item icons.</p>
<p>However, having said all that, I've just noticed that IE doesn't use icons for File &gt; New and File &gt; Open, it only uses them for pages and directories in the Favorites menu. Weird!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2004/01/17/why-is-it-so-difficult-to-add-menu-item-icons-in-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I&#8217;m getting interested in C#</title>
		<link>http://www.itauthor.com/2003/12/19/why-im-getting-interested-in-c/</link>
		<comments>http://www.itauthor.com/2003/12/19/why-im-getting-interested-in-c/#comments</comments>
		<pubDate>Fri, 19 Dec 2003 13:41:54 +0000</pubDate>
		<dc:creator>alistair at home</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/?p=42</guid>
		<description><![CDATA[Why does an averagely sane technical author suddenly start wanting to spend time learning to code in C#? A short personal history, plus a link to a useful website.]]></description>
			<content:encoded><![CDATA[<p>I installed Visual Studio .NET 2003 last night. It took forever to install and by the time it finished I was too knackered to do anything other than check it was working. But I'm now ready to try my hand at a bit of C# programming.</p>
<p>Why am I even thinking about meddling with C#? It may seem a little dumb because I'm a technical author. I don't need to be able to code C#. But the reasons are historical. </p>
<p>In 1989 I was studying publishing and I needed a word processor. I bought myself an Amstrad PCW and fairly soon discovered that what I'd thought was just a glorified typewriter was actually a computer. It ran on the CP/M operating system and had a pretty good version of BASIC called Mallard BASIC. I used this to write simple games. The best of these was a program I called Chomp, which was inspired by PacMan. The trouble was that the more features I added to Chomp (different levels and configurable settings) the slower it ran. </p>
<p>I found out about C and it immediately seemed that a compiled program would obviously run must faster than an interpreted program. So I bought a copy of C for the PCW and started learning how to code in C. Straight away I was impressed by the way C helped you to write logically structured programs. I discovered the beauty of functions, and realised what a mess you can get yourself into with BASIC.</p>
<p>However, I then graduated and got a job and started a family and got married - all at about the same time - and stopped playing around with programming for several years. Then I quit the job I was doing, bought myself a computer and started freelancing. Now that I had a computer again I got back into coding. First I wanted to create an Access database for my business, so that involved learning how to use Visual Basic and learning more about database systems. Then I wanted to have my own website, so inevitably I came to know Perl.</p>
<p>Perl has been my programming language of choice for the last few years. It was originally specifically designed for working with text, so it's my kind of language. It makes sense to me and I find it easy to use. I like the fact that you don't have to worry about what type of data you assign to a variable, Perl figures it all out for you, and things are labelled with $, %, @, # so that you can see what they are at a glance.</p>
<p>But C was always there in the background as my first serious programming language. Over the summer I bought a C book for the first time since I bought the Kernighan and Ritchie book all those years ago, and I took it on holiday with me, with my laptop. I didn't plan to do any coding, but one night I thought I'd recreate a program I first wrote back in 1990, I think. It was the classic sentence builder program. You supply it with arrays of nouns, verbs, adverbs, adjectives, prepositions and conjunctions, and it churns out random, silly, but syntactically correct, sentences.</p>
<p>The kids had great fun running it and plugging in new words. And I felt that it was in some way educational for them - learning a little bit about grammar. Plus I was chuffed that I could still write C code.</p>
<p>So that's pretty much why I'm interested in C#. I pricked up my ears when I first heard about it a couple or so years ago, and I'd like to have some level of proficiency in a language other than Perl. Perl is always going to be more useful to me than C# - just because of what I do for a living and what Perl is very good at doing - but it would be nice to have a second string to my programming bow.</p>
<p>Needless to say, I've been reading up on the subject. I came across this useful website:<br />
<a href="http://www.csharpfriends.com/">http://www.csharpfriends.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2003/12/19/why-im-getting-interested-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting into C#</title>
		<link>http://www.itauthor.com/2003/12/16/getting-into-c/</link>
		<comments>http://www.itauthor.com/2003/12/16/getting-into-c/#comments</comments>
		<pubDate>Tue, 16 Dec 2003 07:55:52 +0000</pubDate>
		<dc:creator>alistair at home</dc:creator>
				<category><![CDATA[C#/Visual Studio/.NET]]></category>

		<guid isPermaLink="false">http://www.itauthor.com/wordpress/?p=39</guid>
		<description><![CDATA[In which I describe my trip to buy Christmas presents, which resulted in me buying C# books for myself. Plus <a href="http://sharptoolbox.madgeek.com/">http://sharptoolbox.madgeek.com/</a>: a site containing a collection of C# development tools.]]></description>
			<content:encoded><![CDATA[<p>I went Christmas shopping at the weekend in Princes Street in Edinburgh. Princes Street is a long, straight street, with shops on one side and Princes Street Gardens on the other side, with Edinburgh Castle high above the gardens. At either end of the street is a Waterstones. I generally start at one end, spend half an hour or so in Waterstones, then fight my way along, through the crowds to the other end (visiting a few shops, as required), then spend maybe an hour in the other Waterstones, then either get a bus, or fight my way back along and pop in for one last browse. Inevitably I come back with more books than anything else, and usually at least some of them are for me.</p>
<p>So at the weekend I spent a good deal of time looking for starter books on C#. The problem was that the books are mainly either all incredibly dry code, code and more code, with no examples of real programs, or, if there are examples, they're all just little command line things. Or they're Visual Studio books that tell you all about how to draw a button and a drop-down list, but don't give you many examples of useful little Windows applications using C# - which is what I was after.</p>
<p>Anyway I settled on a couple of books: C# for Dummies and a nice big book on Visual C#. I'll digest these over Christmas.</p>
<p>When I was looking for C# info on the web I also came across the following site that has a big collection of links to C# development tools:</p>
<p><a href="http://sharptoolbox.madgeek.com/">http://sharptoolbox.madgeek.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itauthor.com/2003/12/16/getting-into-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

