<?xml-stylesheet type="text/xsl" href="/rss.xsl" media="screen"?><rss version="2.0"><channel><title>softlogger Latest Articles ::VB-NET</title><link>http://softlogger.com</link><description>softlogger Latest Articles ::VB-NET</description><ttl>180</ttl><item><title>Changing The Background Color of a TabControl's Tab</title><link>http://softlogger.com/18227/VB-NET/changing-the-background-color-of-a-tabcontrol-s-tab.aspx</link><description>&lt;FONT face=Verdana size=2&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;I've noticed a couple of questions in the VB.NET forums recently where someone wants to change the BackColor of the Tab Header on TabPages. As far as I know, in VB2005 and earlier you have to either use OwnerDraw techniques or subclass your own version of a TabControl. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; In VB2008, WPF offers a much easier route. The equivalent element to a TabPage in Windows Forms is the TabItem in WPF. The WPF TabItem actually has its own Background and Foreground properties, each of which will be applied to the Header Tab. &lt;BR&gt;&lt;BR&gt;Of course you can also set the Background color of the main TabItem page itself via panel type controls with their own Backgrounds set as required. The ListBox in the screenshot demonstrates this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;The following sample is a very basic example of doing this.&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #eaeaea"&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabControl&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="8"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="TabControl1"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabItem&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;Header&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Members"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="LightGreen"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Foreground&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Navy"&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Width&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="150"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="LightGreen"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HorizontalAlignment&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Left"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;J Smith&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;J Jones&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;C B Travis&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;L Fourleather&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabItem&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Green"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Header&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Associates"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Foreground&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Navy" &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabItem&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Background&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="LightBlue"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabItem.Header&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Orientation&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Horizontal" &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Width&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="20"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="CLUB.BMP"/&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Text&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="&amp;nbsp;&amp;nbsp;&amp;nbsp;Sponsors"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Foreground&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Red"/&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabItem.Header&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;J Smith&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;J Jones&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;C B Travis&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;L Fourleather&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TabControl&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;BR&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;The result looks like this: &lt;BR&gt;&lt;BR&gt;&lt;IMG src="http://www.xtabvbcity.plus.com/Blogs/TabItemDemo.jpg"&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;One thing to note is that by default the Header will revert to a White background when it has focus (as shown in the above screenshot). A side effect of this is that you have to be aware that your Foreground will also need to be such that it is visible on both a white background as well as the one you set. To change this behaviour you will probably have to apply a Style or use a ControlTemplate. I haven't fully researched this yet, but plan to write a full article on TabControls and these little tips and tricks in the very near future. But in the meantime if all you need is a more colorful set of headers then WPF supplies the easy answer.&lt;/P&gt;&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/xtab/aggbug/8945.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=18227"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2008-01-14T00:00:00</pubDate><category>VB.NET</category></item><item><title>Share Files Over the Internet from Your Computer with HFS [Featured Windows Download] </title><link>http://softlogger.com/17924/VB-NET/share-files-over-the-inte-net-from-your-computer-with-hfs-featured-windows-download.aspx</link><description>&lt;p&gt;&lt;img alt="HFS.png" src="http://www.lifehacker.com/assets/resources/2008/01/HFS.png" width="300" height="174" class="postimg" align="right" /&gt;Windows only: Freeware application HFS (HTTP File Server) makes it dead simple to run a server to share files from your computer over the web. All you have to do is run the application on the computer with files you want to share, then selectively pick files or directories you want to allow access to. In addition, you can even &lt;em&gt;upload&lt;/em&gt; files to your HFS server from elsewhere. You'll need to set up &lt;a href="http://lifehacker.com/software/feature/special-how-to-access-a-home-server-behind-a-routerfirewall-127276.php"&gt;port forwarding&lt;/a&gt; for port 80 on the computer running HFS and then either remember your public IP address (which may change) or &lt;a href="http://lifehacker.com/software/web-publishing/geek-to-live--how-to-assign-a-domain-name-to-your-home-web-server-124804.php"&gt;assign a name to your home server&lt;/a&gt; (for free) so it's easy to remember. HFS is freeware, Windows only, and weighs in at a svelte 550KB. HFS Advanced mode even supports user accounts.&lt;br /&gt;
&lt;div class="related"&gt;&lt;a href="http://rejetto.com/hfs/"&gt;HFS&lt;/a&gt; [via &lt;a href="http://www.downloadsquad.com/2008/01/03/hfs-offers-quick-and-easy-file-serving/"&gt;Download Squad&lt;/a&gt;]&lt;/div&gt;&lt;/p&gt; &lt;br style="clear: both;"/&gt;
  &lt;img alt=" " style="border: 0; height:1px; width:1px;" border="0" src="http://www.pheedo.com/img.phdo?i=9da12dfaeb58f4a754f555f61659a527" height="1" width="1"/&gt;
&lt;img src="http://www.pheedo.com/feeds/tracker.php?i=9da12dfaeb58f4a754f555f61659a527" style="display: none;" border="0" height="1" width="1" alt=" "/&gt;
&lt;p&gt;&lt;a href="http://feeds.gawker.com/~a/lifehacker/full?a=ev3q1i"&gt;&lt;img src="http://feeds.gawker.com/~a/lifehacker/full?i=ev3q1i" border="0"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.gawker.com/~f/lifehacker/full?a=NetAPcD"&gt;&lt;img src="http://feeds.gawker.com/~f/lifehacker/full?i=NetAPcD" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.gawker.com/~r/lifehacker/full/~4/214755652" height="1" width="1"/&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=17924"&gt;</description><author>Lifehacker</author><pubDate>2008-01-10T00:00:00</pubDate><category>VB.NET</category></item><item><title>Box Clever - The WPF ListBox (2)</title><link>http://softlogger.com/7609/VB-NET/box-clever--the-wpf-listbox-2.aspx</link><description>&lt;FONT face="Comic Sans MS" color=#6666ff size=4&gt;&amp;nbsp;&amp;nbsp;&lt;B&gt;Moving Beyond Simple Strings&lt;/B&gt;&lt;/FONT&gt; &lt;BR&gt;&lt;FONT face=verdana size=2&gt;
&lt;P&gt;&lt;U&gt;&lt;B&gt;&lt;FONT face=Verdana color=#3366cc size=3&gt;Introduction&lt;/FONT&gt;&lt;/B&gt;&lt;/U&gt; &lt;BR&gt;&lt;BR&gt;&amp;nbsp; In the &lt;A href="http://blogs.vbcity.com/xtab/"&gt;previous item on Listboxes &lt;/A&gt;I looked at some ways of tweaking a WPF ListBox which contained only strings. As the&amp;nbsp;range of what can be included in a ListBox is far greater than simple strings, I want now to move on to more complex displays. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;In WPF it is very easy to create listboxes that contain a variety of content types. For example you can list a collection of images one below the other:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.xtabvbcity.plus.com/Articles/WPFListBoxes/ListOfImages.png"&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Although it's not immediately obvious from the screenshot, the second item - the Motor Caravan - is the currently selected item. This is signified by the blue borders to the left and right of the image. There are ways we can improve on this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;A rather fragile version of the XAML code for this ListBox is as follows :&lt;/P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #f9fcc2"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="lstBox1"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="12"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Width&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="99"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="C:\Tent4A.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="C:\Motorhome1.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="C:\caravan.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR&gt;&lt;BR&gt;&lt;U&gt;&lt;B&gt;&lt;FONT face=Verdana color=#3366cc size=3&gt;When is a ListBox Item not a ListBoxItem?&lt;/FONT&gt;&lt;/B&gt;&lt;/U&gt; &lt;BR&gt;&amp;nbsp; 
&lt;P&gt;&amp;nbsp;You may remember that in my &lt;A href="http://blogs.vbcity.com/xtab/archive/2007/09/07/8683.aspx"&gt;earlier ListBox blog example&lt;/A&gt;, I placed each of the strings that I wanted to list inside a separate ListBoxItem. The main reason for doing this was to ensure that each string appeared on a new line. If I had simply listed the strings one after the other (i.e. without enclosing them inside the ListBoxItem tags) then the result would have been a ListBox with one single line which would read: "First Item Second Item Third Item ..." etc. That is, the ListBox would in fact contain only one item.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Another reason for wrapping the strings inside the ListBoxItem tags is to ensure that each item acts in the way we would expect an item in a ListBox to behave. If you don't do this, then the item will behave according to its actual type. So, to come back to our example above where we use a list of images, those images will behave exactly as you would expect &lt;I&gt;images&lt;/I&gt; to behave and not as you may wish ListBoxItems to behave. Often it will not be an important distinction, but it's useful to understand that this is the situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; So the simple answer to the conundrum above "When is a ListBox Item not a ListBoxItem?" is:- "When you don't&lt;I&gt; specifically&lt;/I&gt; make an item in a ListBox a ListBoxItem type.&lt;/P&gt;&lt;BR&gt;&lt;U&gt;&lt;B&gt;&lt;FONT face=Verdana color=#3366cc size=3&gt;Using Resources to Store Images&lt;/FONT&gt;&lt;/B&gt;&lt;/U&gt; 
&lt;P&gt;&amp;nbsp;As I mentioned above, the XAML code to create the ListBox isn't very robust as it uses hard coded paths for the three images. In reality you would probably do one of two things. Either place the images in your project as Resources (see my blog items &lt;A href="http://blogs.vbcity.com/xtab/archive/2007/08/06/8575.aspx"&gt;here&lt;/A&gt; and &lt;A href="http://blogs.vbcity.com/xtab/archive/2007/09/10/8693.aspx"&gt;here&lt;/A&gt; for more info on how to do this). Alternatively, very often you will bind some kind of collection of images (or images and text) to the ListBox. In this article I will only deal with the first alternative, but plan to cover the data binding aspects in a later one.&lt;/P&gt;&lt;U&gt;&lt;B&gt;&lt;FONT face=Verdana color=#3366cc size=3&gt;Combining Images and Text in a ListBox&lt;/FONT&gt;&lt;/B&gt;&lt;/U&gt; 
&lt;P&gt;&amp;nbsp; Let's take a look at a basic ListBox layout that combines an image with text. Here is one example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="http://www.xtabvbcity.plus.com/Articles/WPFListBoxes/ImagesandText1.png"&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;In this example the third item is currently selected and highlighted in blue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;What you see in the screenshot is a ListBox which contains three ListBoxItems. Each ListBoxItem includes both an image and some text. Now, you may well be tempted to try and code it like so: &lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #fcfdc4"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Images/Tent4A.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Tent - Grassed areas only&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; But if you do that, then all you would get for your effort is a syntax error telling you that the Content property is declared twice. The ListBoxItem can only contain one child. This is a very common theme in XAML and you soon learn that in order to display multi layered elements all you have to do is to place sub-elements and sub-sub-elements and so on inside new container controls - the Russian Doll approach. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;To create this first example, all I have done is create a StackPanel - which is obviously a container control by its very nature - and placed the Image as well as the text inside the StackPanel. (If you want an introduction to the basics of the StackPanel, check out my earlier &lt;A href="http://blogs.vbcity.com/xtab/archive/2007/09/10/8694.aspx"&gt;blog item here&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The StackPanel won't take the text as a plain string in the way that a ListBoxItem will. So the way round this is to place the text inside a TextBlock. (A TextBlock is a control whose sole purpose in life is to display text in a format of your choice - a label with attitude!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;So here is the XAML code so far:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #fcfdc4"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="lstBox1"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="12"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;HorizontalContentAlignment&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Center"&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Images/Tent4A.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Tent - Grassed areas only&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 60pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Images/Motorhome1.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Motor home - Hard standing only&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Images/Caravan.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Caravan - Grassed areas or Hard standing&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;For all that it may be a bit verbose, I don't think anyone could argue that this visual tree is hard to follow - in the sense that each step of the creation procedure of each element is laid out and clear to see. I've previously touched on ways of reducing the bloat, such as using Styles. In a future blog I will cover Control Templates, which is another immensely powerful route to reducing repetition, among other benefits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If you click with the mouse on any part of a ListBoxItem or its contents then you are able to use that event in whatever way you choose by means of the code behind. The VB.NET code will work in just the same way as you are familiar with in Windows Forms. There are several differences in the syntax, but the general thrust is the same. So in the VB.NET partial class behind your window you might have something like: &lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #fcfdc4"&gt;&lt;FONT color=#0000ff&gt;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; lstBox1_SelectionChanged(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Object&lt;/FONT&gt;,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Windows.Controls.SelectionChangedEventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; lstBox1.SelectionChanged&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine(&lt;FONT color=#a31515&gt;"You selected item # "&lt;/FONT&gt; &amp;amp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lstBox1.SelectedIndex.ToString)&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Or maybe something slightly more realistic, such as displaying the locations of grass pitches so that one can be allocated:-&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #fcfdc4"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; lstBox1_SelectionChanged(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Object&lt;/FONT&gt;,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Windows.Controls.SelectionChangedEventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; lstBox1.SelectionChanged&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;Select&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Case&lt;/FONT&gt; lstBox1.SelectedIndex&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case&lt;/FONT&gt; 0&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/FONT&gt; gpl&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; New&lt;/FONT&gt; GrassPitchesLayout&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gpl.ShowDialog()&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Select&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;One important feature to note here is that in WPF it is possible to identify and isolate exactly which sub-element was selected. So in the XAML example above, the clicking of any part of the ListBoxItem will fire the SelectionChanged event, exactly as you would expect. However, if for some reason you also wanted to know if the user had clicked on the tent image within that ListBoxItem (i.e not on the text or any of the white space areas), then this information is very easily obtainable, so long as you assign a Name to the Image element. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;In the following example, the Image in the first ListBoxItem is assigned the Name "Tent" :-&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #fcfdc4"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="lstBox1"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="12"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;HorizontalContentAlignment&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Center"&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Images/Tent4A.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Tent"/&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Tent - Grassed areas only&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;&lt;BR&gt;&lt;!--  More items follow --&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;That Image is now accessible in the code behind by its name. The following code snippet uses the MouseDown event &lt;I&gt;of the Image&lt;/I&gt; to display some information:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #fcfdc4"&gt;&lt;FONT color=#0000ff&gt;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; Tent_MouseDown(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Object&lt;/FONT&gt;,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Windows.Input.MouseButtonEventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; Tent.MouseDown&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine(&lt;FONT color=#a31515&gt;"You clicked on the tent image"&lt;/FONT&gt;)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;At this point you might be wondering if the Image MouseDown event somehow cancels out the ListBox SelectionChanged event. The answer is that it doesn't. Both events fire; my experiments show that the Image MouseDown fires first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;If you're really inquisitive, you might also wonder what happens if the user traverses the ListBox using the keyboard and not the mouse. Somewhat confusingly (to me anyway), the MouseDown event of the Image fires whenever that first item is selected via the keyboard arrow keys. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;Anyway, this ability to access elements with the mouse is something that you may be glad you knew about at some point in your future coding. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;U&gt;&lt;B&gt;&lt;FONT face=Verdana color=#3366cc size=3&gt;Other Layout Combinations&lt;/FONT&gt;&lt;/B&gt;&lt;/U&gt; 
&lt;P&gt;&amp;nbsp; It is probably more traditional in cases where you have an image and some text to see the image at the left and the text placed to the right. So let's fix that now: &lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #fcfdc4"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="lstBox1"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="12"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;HorizontalContentAlignment&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Left"&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Orientation&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Horizontal"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Images/Tent4A.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Tent - Grassed areas only&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;&lt;BR&gt;&lt;!--  More items follow --&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;You will see from the code above that I changed the Orientation of the StackPanels to Horizontal. The default previously was Vertical.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;If you're particularly eagle-eyed you may have noticed that I also changed the HorizontalContentAlignment of the ListBox itself from Center to Left. This forces the three items to be neatly lined up at the left side of the ListBox.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The result of the above code is:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.xtabvbcity.plus.com/Articles/WPFListBoxes/TraditionalList.png"&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;But, you know, we can do much better than that. What's the point of having this sophisticated layout tool if we don't use it to move from the bog standard plain text to something a little better?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG alt="An improved layout for the ListBox" src="http://www.xtabvbcity.plus.com/Articles/WPFListBoxes/BetterList.png"&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Or:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="http://www.xtabvbcity.plus.com/Articles/WPFListBoxes/ListBoxWithBorders.png" ?&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;OK, so they won't win any Designer of the Year prizes, but I think you can see that there is huge potential for creating individual user interfaces - and much more easily than you could hope to do with standard Windows Forms. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;The XAML code for the above ListBox is:-&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #fcfdc4"&gt;&lt;FONT color=#0000ff&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="lstBox1"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="12"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;HorizontalContentAlignment&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Left"&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;FontFamily&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Verdana" &amp;gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="0,3,0,3"&amp;gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Border&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; BorderBrush&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="DeepSkyBlue"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; BorderThickness&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; CornerRadius&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Width&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="258"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Orientation&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Horizontal"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="3"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Image&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Source&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Images/Tent4A.jpg"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2" /&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="5"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Padding&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="2"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; FontSize&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="13"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;FontWeight&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Bold"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Foreground&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Navy"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt; Tent&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Margin&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="8"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Padding&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="8,2,2,2"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; FontSize&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="11"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; 
&lt;DIV style="MARGIN-LEFT: 20pt"&gt;FontWeight&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Normal"&lt;/FONT&gt;&lt;FONT color=#ff0000&gt; Foreground&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;="Green"&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;Grassed areas only&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;TextBlock&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;Border&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBoxItem&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;&lt;BR&gt;&lt;!--  More items follow --&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/DIV&gt;&lt;/&lt; FONT&gt;&lt;FONT color=#a31515&gt;ListBox&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;If you want to see the ListBox pushed to the limits, then check out a couple of demos from Josh Smith and Bea Costa which go way beyond the standard image+text layout that I have covered so far. &lt;BR&gt;
&lt;P&gt;&amp;nbsp;First there is Josh's Sliding ListBox:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="http://www.xtabvbcity.plus.com/Articles/WPFListBoxes/JoshSlidingListBox.png"&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;More details on the code &lt;A href="http://www.codeproject.com/WPF/SlidingListBox.asp"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;And taking the ListBox to extremes (literally) is Bea Costa's Planet ListBox:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.xtabvbcity.plus.com/Articles/WPFListBoxes/BeaCostaPlanets.png"&gt; &lt;/P&gt;&lt;BR&gt;Yep - that really is a ListBox and clicking on a planet makes that planet the selected item! More details can be found &lt;A href="http://www.beacosta.com/blog/?p=40"&gt;here&lt;/A&gt;. 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I plan to write a future blog item that takes the caravan example a step further and uses data binding to automatically populate the listbox items. In the meantime I hope you've found this description of the basics to be useful.&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/xtab/aggbug/8720.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=7609"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2007-09-20T00:00:00</pubDate><category>VB.NET</category></item><item><title>Windows Forms - Aligning Two Forms</title><link>http://softlogger.com/11875/VB-NET/windows-forms--aligning-two-forms.aspx</link><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp; This tip barely qualifies as a Gotcha! but I have seen some people get stuck with it, so thought it worth a mention.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp; If you want to control exactly where a second form is placed in relation to another form, you can use code that shifts the second form to either side or above or below the first one.&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp; The key is to ensure that you set the StartPosition of the forms to "Manual".&amp;nbsp;&amp;nbsp; If you do this, each form in the project that i set to Manual will automatically be placed at position 0,0 - i.e top left of the screen.&amp;nbsp; (By default this property&amp;nbsp;is set to "WindowsDefaultLocation").&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp; So, to take a scenario with two forms, you can leave Form1 as-is and set the location of Form2 relative to Form1.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp; For example to align the two forms horizontally but with Form2 placed immediately to the Right of Form1 you could use:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/P&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #f7f7f0"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/FONT&gt; F2&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; New&lt;/FONT&gt; Form2&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F2.Left =&lt;FONT color=#0000ff&gt; Me&lt;/FONT&gt;.Width + 2&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F2.Top =&lt;FONT color=#0000ff&gt; Me&lt;/FONT&gt;.Top&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F2.Show()&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT face=Verdana size=2&gt; As you can see the calculation is based on the width of the first form, plus a small margin added for appearance's sake.&lt;/FONT&gt;&amp;nbsp; &lt;FONT face=Verdana size=2&gt;The result&amp;nbsp; is:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;IMG src="http://www.xtabvbcity.plus.com/Blogs/WinFormsAlignment1.png"&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;FONT face=Verdana size=2&gt;It's simple to use the same approach to place the second form anywhere you wish in relation to the first.&amp;nbsp; Below it, for example:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;
&lt;DIV style="MARGIN-LEFT: 13pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #f7f7f0"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/FONT&gt; F2&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; New&lt;/FONT&gt; Form2&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F2.Left =&lt;FONT color=#0000ff&gt; Me&lt;/FONT&gt;.Left&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F2.Top =&lt;FONT color=#0000ff&gt; Me&lt;/FONT&gt;.Height + 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;F2.Show()&lt;FONT color=#a31515&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT face=Verdana size=2&gt;So, just use whatever offset suits your needs, and don't forget to change that StartPosition property first.&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/xtab/aggbug/8573.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=11875"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2007-08-05T00:00:00</pubDate><category>VB.NET</category></item><item><title>VB 2005: How To Hide / Show Multiple TabPages in a TabControl</title><link>http://softlogger.com/7242/VB-NET/vb-2005-how-to-hide--show-multiple-tabpages-in-a-tabcontrol.aspx</link><description>&lt;FONT face=Verdana size=2&gt;
&lt;P&gt;&amp;nbsp;&lt;U&gt;Introduction&lt;/U&gt;&lt;BR&gt;In the previous parts we looked at ways of hiding and showing a single Tab Page in a TabControl. In some situations you may need to hide and show multiple pages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This is still fairly easy to do, but now you need a collection in which to hold the TabPages you have removed. (Remember from the previous descriptions that you are not really &lt;I&gt;hiding&lt;/I&gt; the TabPages, you are in fact completely removing them, but storing a copy in memory that you can later call on to reinstate the page) &lt;/P&gt;
&lt;P&gt;&lt;U&gt;A Collection of Saved TabPages&lt;/U&gt;&lt;BR&gt;In VB2005 the availability of generic collections makes our life very easy and we can create type safe collections automatically. In this case we will create a List and this list will only allow TabPage objects to be stored in it. Here is the code that does this:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;A collection of removed TabPages&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/FONT&gt; colRemovedTabs&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; New&lt;/FONT&gt; List(&lt;FONT color=#0000ff&gt;Of&lt;/FONT&gt; TabPage)&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;U&gt;Allowing User to Select&lt;/U&gt;&lt;BR&gt;For demonstration purposes we need a way of listing all available TabPages. Whether this list is visible to the user and/or how it is displayed will depend on your particular application. For this article I will list all the TabPages in a standard ListBox control.. This list box will be populated when the form is first loaded: &lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; Form1_Load(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Object&lt;/FONT&gt;,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.EventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Me&lt;/FONT&gt;.Load&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Each&lt;/FONT&gt; tabpg&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; TabPage&lt;FONT color=#0000ff&gt; In&lt;/FONT&gt; TabControl1.TabPages&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Me&lt;/FONT&gt;.ListBox1.Items.Add(tabpg.Text)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ListBox1.SelectionMode = SelectionMode.MultiSimple&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The final line of code inside that procedure is there simply to ensure that the user can select more than one TabPage at a time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Now the user can simply select multiple items (TabPages) from the listbox. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;U&gt;Removing and Saving&lt;/U&gt;&lt;BR&gt;Once they have made their selection, a button click is used to confirm that those pages should be hidden/removed. The click event code is as follows:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; Button7_Click(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Object,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.EventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; Button7.Click&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;' Hide multiple pages&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Each&lt;/FONT&gt; tabpg&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; TabPage&lt;FONT color=#0000ff&gt; In&lt;/FONT&gt; TabControl1.TabPages&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Each&lt;/FONT&gt; item&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; String&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; In&lt;/FONT&gt; ListBox1.SelectedItems&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&lt;/FONT&gt; tabpg.Text = Trim(item)&lt;FONT color=#0000ff&gt; Then&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;colRemovedTabs.Add(tabpg)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TabControl1.Controls.Remove(tabpg)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; If&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;All we have here is a nested loop. Firstly we loop through all of the TabPages in the TabControl. Inside that loop, we also loop through all the selected items in the listbox. &lt;BR&gt;If we find a match between the selected item and the text (the string used on the Tab of a TabPage) then we know this item needs to be hidden.. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;We store its information in the collection (colRemovedTabs) before removing it from the TabControl. The approach is very similar to that used in the earlier single TabPage examples. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;U&gt;Reinstating Removed TabPages&lt;/U&gt;&lt;BR&gt;Reinstating the TabPages is also an easy task. We have them all saved in the collection, so we can simply dip in and grab them all.&lt;/P&gt;
&lt;P&gt;Once again I've placed this in a Button Click event for demo purposes:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; Button8_Click(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Object,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.EventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; Button8.Click&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Reinsert all removed pages&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Each&lt;/FONT&gt; savedTab&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; TabPage&lt;FONT color=#0000ff&gt; In&lt;/FONT&gt; colRemovedTabs&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TabControl1.Controls.Add(savedTab)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;' Clear the collection as it has now done its work&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;colRemovedTabs.Clear()&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; You will see that I have also cleared out the contents of the collection as the last code task. If you don't do this then further clicks of the button will result in duplicate TabPages being added back to the TabControl; probably not what you want in most situations.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Summary&lt;/U&gt;&lt;BR&gt;
&lt;P&gt;It is also fairly easy to reinstate only certain hidden TabPages. The code for this is included in the demo solution which you can download from &lt;A href="http://www.xtabvbcity.plus.com/Blogs/TabPages%20Hide%20Demo.zip"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;The completed project looks like this:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://www.xtabvbcity.plus.com/Blogs/TabPageDemoUI.png"&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; So now you have seen how to "hide" and "show" individual or multiple TabPages. As I said at the start of the first part of these articles, this is one of those simple looking tasks that takes a bit more effort than you first think, but really isn't very difficult once you realise that you can work round the limitations.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/xtab/aggbug/8508.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=7242"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2007-07-18T00:00:00</pubDate><category>VB.NET</category></item><item><title>Hiding a TabPage (2) - User's Selection</title><link>http://softlogger.com/7246/VB-NET/hiding-a-tabpage-2--user-s-selection.aspx</link><description>&lt;FONT face=Verdana size=2&gt;
&lt;P&gt;In the previous part I looked at a very simple scenario where the developer knew in advance which TabPage should be hidden and re-shown. Next we'll look at doing the same thing, except that this time the user gets to choose which TabPage is hidden. &lt;/P&gt;
&lt;P&gt;As in the previous example, you're going to need some kind of trigger to kickstart the Hide or Show activity. I've used a button placed outside the TabControl on the form itself, but you could use any other trigger that suits your purpose - e.g. a button or checkbox inside a TabPage. &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Locations TabPage has focus" src="http://www.xtabvbcity.plus.com/Blogs/FocussedTabPage.jpg"&gt;&lt;/P&gt;
&lt;P&gt;In fact of course it doesn't even have to be wired up to the clicking on a Windows Forms Control - you could hide the TabPage based on some kind of text input from the user.&lt;/P&gt;
&lt;P&gt;Anyway, in this example, the button click code needs to :&lt;BR&gt;
&lt;UL&gt;
&lt;LI&gt;Identify which TabPage currently has focus &lt;BR&gt;
&lt;LI&gt;Then store this TabPage's metadata in the TempTab variable &lt;BR&gt;
&lt;LI&gt;Before finally Removing the TabPage from the TabControl. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Here is the code I've used:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; Button3_Click(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Object,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.EventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; Button3.Click&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Identify the TabPage to be removed&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Each&lt;/FONT&gt; tp&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; TabPage&lt;FONT color=#0000ff&gt; In&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Me&lt;/FONT&gt;.TabControl1.TabPages&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&lt;/FONT&gt; tp.Focus =&lt;FONT color=#0000ff&gt; True&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Then&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TempTab = tp&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TabControl1.TabPages.Remove(tp)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Exit&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; For&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; If&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I think that code is pretty straightforward. To identify the single Tabpage that currently has focus you have to enumerate through all of them until you find the right one. &lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp; For Each tp As TabPage In Me.TabControl1.TabPages &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If tp.Focus = True Then&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Once you've located it, store it in TempTab;&lt;BR&gt;then remove it:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;TempTab = tp &lt;BR&gt;&amp;nbsp;&amp;nbsp; TabControl1.TabPages.Remove(tp)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Finally (and crucially) don't forget to jump out of the loop once you have found your TabPage and taken the appropriate action on it.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp; Exit For&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Why? Because what happens when you remove a Tabpage is that Focus automatically shifts to the first TabPage in the TabControl. Therefore if you don't jump out of the loop, it will keep finding TabPages that have focus, one after the other, and will keep removing them until all are gone. You won't get an Exception, but you won't have any TabPages either! (And only the most recently deleted one will be available for reshowing; you will have permanently lost all the others.)&lt;/P&gt;
&lt;P&gt;OK, the code to show the TabPage again is simple:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;TabControl1.TabPages.Add(TempTab) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;As mentioned earlier, you will get unwanted results if you allow this button to be clicked more than once consecutively, so I advise that you add further code to avoid this happening. I will post up a downloadable sample project that includes this, but for conciseness won't deal with it in this blog. &lt;/P&gt;
&lt;P&gt;So that would seem to fix the "Remove user's choice of TabPage" problem easily enough. But what if for some reason it's important to reinstate the saved tabPage back in the TabControl in its original position?&lt;/P&gt;
&lt;P&gt;All sorts of ways of doing this spring to mind, but just because I want to keep this part really uncomplicated, I'm simply going to set up a second variable, call it TempTabIndex and make it an Integer Type. &lt;BR&gt;We will save the TabPage to TempTab as before and save the index value to TempTabIndex. &lt;/P&gt;
&lt;P&gt;Here's the code:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Identify the Index Number of the selected TabPage&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;With&lt;/FONT&gt; TabControl1&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/FONT&gt; i&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Integer&lt;/FONT&gt; = 0&lt;FONT color=#0000ff&gt; To&lt;/FONT&gt; .TabPages.Count - 1&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&lt;/FONT&gt; .TabPages(i).Focus =&lt;FONT color=#0000ff&gt; True&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Then&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Save the details of this TabPage&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TempTab = .TabPages(i)&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Save its index number&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TempTabIndex = i&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Remove it&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TabPages.RemoveAt(i)&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Stop looking for Tabpages with Focus&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Exit&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; For&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; If&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; With&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;As you can see, instead of enumerating through the TabPages what we do here is iterate through the TabControl's TabPages collection, an index at a time. &lt;BR&gt;Once we find the TabPage that has focus, we can also easily grab the current index number and store that, as well as storing the tabPage data in the same way as we did previously. &lt;/P&gt;
&lt;P&gt;And again as in the earlier example, it's important to ensure that you jump out of that loop as soon as you've completed the work on the one TabPage we're interested in.&lt;/P&gt;
&lt;P&gt;Reinserting the TabPage back into its correct original position simply requires us to pass in the Index number and the TabPage name to the TabControl's.TabPages Insert method:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; Button6_Click(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Object,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.EventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; Button6.Click&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Reinsert TabPage in correct position&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TabControl1.TabPages.Insert(TempTabIndex, TempTab)&lt;FONT color=#0000ff&gt;&lt;BR&gt;&lt;BR&gt;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The project described in these first two parts now looks something like this:&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Single TabPages" src="http://www.xtabvbcity.plus.com/Blogs/SingleTabPages.jpg"&gt;&lt;/P&gt;
&lt;P&gt;In the next part I want to look at a more complex situation; one where more than one TabPage is hidden at a time.&lt;/P&gt;&lt;/ Font&gt;&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/xtab/aggbug/8473.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=7246"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2007-06-29T00:00:00</pubDate><category>VB.NET</category></item><item><title>VB 2005:  How To Hide and Show a TabPage in a TabControl</title><link>http://softlogger.com/7222/VB-NET/vb-2005--how-to-hide-and-show-a-tabpage-in-a-tabcontrol.aspx</link><description>&lt;FONT face=Verdana size=2&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT face=Arial&gt;AfterNote:&amp;nbsp;&amp;nbsp; There are now three blog items on this topic, each showing a different aspect&amp;nbsp; If you want to view them all as one article, follow &lt;A href="ftp://www.xtabvbcity.plus.com/htdocs/Articles/Hide%20TabPages%20Article.htm"&gt;this link&lt;/A&gt;)&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT face=Arial&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/EM&gt;Sometimes you may want to hide a TabPage from the user's view, but you don't want to permanently remove it. &amp;nbsp; Now, if you've checked out the TabPage's methods you will see that it does have a "Hide" method in VB 2005. That's great, but the trouble is if you try using it, it doesn't work! &amp;nbsp; You won't get an Exception, but you won't get a disappearing Tab Page either. (And if you're using an earlier version of VB.NET you have a choice of Hide or the Visible property, but neither will have the effect you want if you try using them.) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;Actually, the way to hide a TabPage is to access it through its parent container - the TabControl itself. We'll take a look at how to do this. (and possibly how to sidestep other problems along the way).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Let's start with the situation where you know that you are only going to want to hide and show one specific TabPage in a TabControl which has a set number of TabPages. &lt;/P&gt;
&lt;P&gt;First, you need somewhere to store the info about the TabPage. In this scenario a simple variable will do:-&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;A temp variable to hold a single hidden Page&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/FONT&gt; TempTab&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; TabPage&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The code goes at the top of the form, outside any procedures.&lt;/P&gt;
&lt;P&gt;Next, in the event you are using to trigger the hide action, (maybe a button click - see the "Hide TabPage 2" button in the screenshot below),&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Simple preselected TabPage" src="http://www.xtabvbcity.plus.com/Blogs/Preselected%20Tab.jpg"&gt;&lt;/P&gt;
&lt;P&gt;you store the chosen TabPage in that TempTab variable.&lt;BR&gt;And finally you use the Remove or RemoveAt method to physically delete the TabPage from within the TabControl.&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;TempTab = TabControl1.TabPages(1)&lt;BR&gt;TabControl1.TabPages.RemoveAt(1)&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Because we knew in advance that we would be hiding and removing the second TabPage (whose Index is 1, of course), we can use the RemoveAt method. This is the most straightforward approach to use in this situation. So the situation currently is that the TabPage no longer exists in the TabControl, but you have squirrelled away a copy in that TempTab variable for later use. &lt;/P&gt;
&lt;P&gt;What we need to look at next is reinstating the hidden TabPage when needed. Again this is quite simple. We insert the TabPage back into the TabControl, taking care to insert it in its proper original position. &lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; Button2_Click(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Object,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.EventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; Button2.Click&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TabControl1.TabPages.Insert(1, TempTab)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The parameters of that Insert method are the Index to Insert at (Index 1, in this case, as that's where it came from) and the TabPage itself, as identified by its name. (Don't confuse its name with its Text. In this example they happen to be the same, but in a real world example this is unlikely to be the case).&lt;/P&gt;
&lt;P&gt;If you're wondering about the purpose of the TextBox in that screenshot, I put it in so you could really prove to yourself that this does work. &lt;/P&gt;
&lt;P&gt;If you create a Form as shown and enter some text into the TextBox at runtime and then Save/Remove the TabPage you want to be sure that any data input by the user really does get saved too. So, run the project, enter your name, hit the first button to hide the TabPage, then hit the second one to show it again. As you will see, even dynamically entered data, such as the text in the textBox, is saved and reinstated. &lt;/P&gt;
&lt;P&gt;To re-emphasise the point I made earlier about the &lt;I&gt;Name&lt;/I&gt; of the TextBox being used as the key parameter, not the &lt;I&gt;Text&lt;/I&gt; that the user sees on the Tab, take a look at the following screenshot:&lt;/P&gt;
&lt;P&gt;&lt;IMG alt=" TabPage Text Changed" src="http://www.xtabvbcity.plus.com/Blogs/TabPageTextChanged.jpg"&gt;&lt;/P&gt;
&lt;P&gt;The same code as used above will work perfectly with these TabPages, because I have only changed the Text and not the Name.&lt;/P&gt;
&lt;P&gt;By the way, if you don't need or want to reinsert the TabPage back in the position you took it out from, you can simply have it placed at the end of the current collection by using:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TabControl1.TabPages.Add(TempTab)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;instead. &lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Added at end" src="http://www.xtabvbcity.plus.com/Blogs/TabPageAdded.jpg"&gt;&lt;/P&gt;
&lt;P&gt;However, one little Gotcha to watch out for (it's obvious when you think about it, but ...) is that if you use the "Show" button more than once then you will get multiple TabPages added; each of which has the same Text and - more importantly - each of which has the same Name. &lt;BR&gt;However, not so obvious, and even worse, is that this multiplicity of Tabpages with the same name gives the compiler such a headache that in fact you will lose all the controls and formatting from all copies of that TabPage. Not something that you would normally want to happen, so you should include code to restrict the Hiding/Showing to single instances.&lt;/P&gt;
&lt;P&gt;So far, so good. In the next part we'll look at a slightly more complex scenario. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/xtab/aggbug/8465.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=7222"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2007-06-25T00:00:00</pubDate><category>VB.NET</category></item><item><title>How To Print A Form To Printer in VB 2005</title><link>http://softlogger.com/7208/VB-NET/how-to-print-a-form-to-printer-in-vb-2005.aspx</link><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;a.k.a.&amp;nbsp; The Power of the PrintForm Power Pack!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&lt;U&gt;Introduction&lt;/U&gt; &lt;BR&gt;Let's face it, ease of printing in VB.NET has never been its main selling point. In fact, because you literally have to draw most of what you want transferred to paper (or save some kind of screen capture to an image file and then print that), it really can be a bit of a pain.&lt;/P&gt;
&lt;P&gt;I knew that the Microsoft VB Team had created an additional Power Pack which prints Windows Forms directly to the printed page but hadn't got round to trying it until today. I have to say that I'm impressed with its ease of use, the comprehensive help that comes with it and, in fact, the range of options available.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Downloading and Installing &lt;/U&gt;&lt;BR&gt;The Pack is available as a free download from &lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=286111b0-6965-46cc-bf6f-c5ee63b1f98c&amp;amp;displaylang=en"&gt;here&lt;/A&gt;.&amp;nbsp; Once you download, run and install the pack you are then able to add the PrintForm component to your ToolBox. I used the VB 2005 Express Edition to trial this, as the Pro and higher editions come with Crystal Reports bundled. That said, this component is so easy to use that you may well prefer it over CR for anything but the most complex displays. &lt;/P&gt;
&lt;P&gt;If all goes well, you will automatically be presented with a comprehensive HTML based help page. If you don't see it, or you want to refer to it again later, it is saved by default to &lt;I&gt;C:\Program Files\Microsoft Visual Basic 2005 Power Packs\Printing\PrintForm Component 1.0\Documentation\PrintFormHelp.htm&lt;/I&gt; &lt;BR&gt;There is also a demo solution included in that PrintForm Component 1.0 folder.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Adding the Component to the Toolbox&lt;/U&gt;&lt;BR&gt;Once installed on your system, adding the item to your Toolbox follows standard procedure. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Right Click your mouse in the Toolbox. &lt;BR&gt;&amp;nbsp;&amp;nbsp; Select "Choose Items" from the context menu that appears. &lt;BR&gt;&amp;nbsp;&amp;nbsp; In the Choose Toolbox Items dialog box, navigate to the .NET Framework Components list. &lt;BR&gt;&amp;nbsp;&amp;nbsp; Select the PrintForm item from this list and check its checkbox.&lt;BR&gt;&amp;nbsp;&amp;nbsp; Click OK to add it to the Toolbox. &lt;/P&gt;
&lt;P&gt;&lt;U&gt;Trying It Out&lt;/U&gt; &lt;BR&gt;Before I spotted that demo solution, I'd given it a run out myself to see if it worked as advertised. The form I created had some standard controls - PictureBox, RichTextBox, Label, TextBox and Button. &lt;BR&gt;I also used GDI+ to draw some circles on the form using the OnPaint event. I thought it might be useful to see how the component would handle those :&lt;/P&gt;
&lt;P&gt;&lt;IMG alt="Windows Form" src="http://www.xtabvbcity.plus.com/Blogs/FormToPrint.jpg"&gt;&lt;/P&gt;
&lt;P&gt;As you can see, the RichTextBox content contains coloured text as well as a block of text that is highlighted. &lt;/P&gt;
&lt;P&gt;I wanted the form to be printed WYSIWYG - well, almost. I decided that it would be better if the button wasn't printed to paper.&lt;/P&gt;
&lt;P&gt;So that was my requirement: print everything on the form except the button. &lt;BR&gt;How easy was it? Simple!&lt;BR&gt;How successful was it? Totally!&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Step By Step&lt;/U&gt;&lt;BR&gt;Obviously, the first thing to do is to drag an instance of the PrintForm component on to your form. (Although I say "obviously", in reality you don't need to do so; you can always programmatically create an instance in your code if you wish). Anyhow, assuming you've gone the Toolbox instance route you will see that a PrintForm component named PrintForm1 now sits in the component tray at the base of your Design Window. You can now code against this component using the various methods and properties available. &lt;/P&gt;
&lt;P&gt;First though, here's the code I used to populate the RichTextBox: &lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; Form1_Load(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Object&lt;/FONT&gt;,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.EventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Me&lt;/FONT&gt;.Load&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RichTextBox1.LoadFile(&lt;FONT color=#800000&gt;"C:\readme.rtf"&lt;/FONT&gt;, RichTextBoxStreamType.RichText)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;And the following code in the OnPaint event draws those two circles round the PictureBox:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;Protected&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Overrides&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; OnPaint(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Windows.Forms.PaintEventArgs)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MyBase&lt;/FONT&gt;.OnPaint(e)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/FONT&gt; p&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; Pen =&lt;FONT color=#0000ff&gt; New&lt;/FONT&gt; Pen(Color.Coral, 3)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Graphics.DrawEllipse(p,&lt;FONT color=#0000ff&gt; New&lt;/FONT&gt; Rectangle(70, 35, 140, 140))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p =&lt;FONT color=#0000ff&gt; New&lt;/FONT&gt; Pen(Color.Aquamarine, 3)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e.Graphics.DrawEllipse(p,&lt;FONT color=#0000ff&gt; New&lt;/FONT&gt; Rectangle(65, 30, 150, 150))&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;And so to the code that will do the hard work for us and print the form to a printer:&lt;/P&gt;
&lt;P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;Private&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt; PrintButton_Click(&lt;FONT color=#0000ff&gt;ByVal&lt;/FONT&gt; sender&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.Object,&lt;FONT color=#0000ff&gt; ByVal&lt;/FONT&gt; e&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt; System.EventArgs)&lt;FONT color=#0000ff&gt; Handles&lt;/FONT&gt; btnPrint.Click&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;' Hide the button&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;btnPrint.Visible =&lt;FONT color=#0000ff&gt; False&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Assign this form as the form to be printed&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PrintForm1.Form =&lt;FONT color=#0000ff&gt; Me&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Optional - Remove highlight from textbox&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;(Otherwise it will be printed)&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TextBox1.SelectionStart = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TextBox1.SelectionLength = 0&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Do the printing&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PrintForm1.Print()&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;&amp;nbsp;Redisplay Button&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;btnPrint.Visible =&lt;FONT color=#0000ff&gt; True&lt;BR&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I think you'll agree that it is very simple and the commenting in the code needs no further explanation. &lt;/P&gt;
&lt;P&gt;&lt;U&gt;Other Options &lt;/U&gt;&lt;BR&gt;Although I have seen several good examples where a screenshot has been used to save a displayed form to file and the file is then printed, these all seem to suffer from the same problem - if the form is larger than the screen, only the visible area will be saved. &lt;BR&gt;The PrintForm component handles this problem very effectively with the Scrollable&amp;nbsp;PrintOption.&lt;/P&gt;
&lt;P&gt;It is simple to use and if you want to print everything on the form - even if it is off the screen then this code syntax will do the job:&lt;/P&gt;
&lt;DIV style="MARGIN-LEFT: 10pt; MARGIN-RIGHT: 2pt"&gt;
&lt;DIV style="FONT-SIZE: 10pt"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #e8e8e8"&gt;PrintForm1.Print(&lt;FONT color=#0000ff&gt;Me&lt;/FONT&gt;, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;It really is as simple as that. The PrintOptions also include choices as to whether you print out the Title Bar or just the client area.&lt;/P&gt;
&lt;P&gt;Altogether, this is a very useful package - well done the team who put this together to resolve a long running criticism of this particular VB.NET feature.&lt;/P&gt;&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/xtab/aggbug/8452.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=7208"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2007-06-19T00:00:00</pubDate><category>VB.NET</category></item><item><title>VB 2005: The "Missing" Sub Main Problem</title><link>http://softlogger.com/7207/VB-NET/vb-2005-the-missing-sub-main-problem.aspx</link><description>&lt;FONT face=Verdana size=2&gt;
&lt;P&gt;As I've said on many occasions in the past, it's those sometimes tiny little Gotchas that will cause you the greatest amount of aggravation. Here's one that I've been meaning to blog for a while now. It's a question/problem that comes up fairly often and it usually goes something like this:- &lt;/P&gt;
&lt;P&gt;&lt;I&gt;"In a Windows Forms project, I add a module that has a Sub Main procedure in it. I want to use this Sub Main as the StartUp Object in the application. But when I look in the project properties, I don't see "Sub Main" as a choice. " &lt;/I&gt;&lt;BR&gt;&lt;BR&gt;&lt;IMG alt="No Sub Main Listed" src="http://www.xtabvbcity.plus.com/Blogs/NoSubMainListed.jpg"&gt; &lt;BR&gt;&lt;I&gt;"It used to be here in earlier editions - where has it gone to and how can I access it? "&lt;/I&gt; &lt;/P&gt;
&lt;P&gt;The solution to this particular Gotcha is very easy. &lt;/P&gt;
&lt;P&gt;Open up the Project Properties page. &lt;BR&gt;Home in on the "Enable Application Framework" CheckBox. &lt;BR&gt;&lt;BR&gt;&lt;IMG alt="Enable Application Framework" src="http://www.xtabvbcity.plus.com/Blogs/EnableApplicationFramework.jpg"&gt; &lt;BR&gt;Uncheck this option (i.e. disable it)&lt;/P&gt;
&lt;P&gt;Now if you view the "Startup Form" combo you'll see that it has changed so that it reads "Startup Object". &lt;BR&gt;Click on the combo and all the forms plus the module and the Sub Main inside that module will all be available as Startup objects.&lt;/P&gt;&lt;BR&gt;&lt;IMG alt="Sub Main Now Listed" src="http://www.xtabvbcity.plus.com/Blogs/SubMainListed.jpg"&gt; 
&lt;P&gt;It's one of those "simple when you know" things that'll drive you mad if you don't!&lt;/P&gt;&lt;/FONT&gt;&lt;img src ="http://blogs.vbcity.com/xtab/aggbug/8453.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=7207"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2007-06-19T00:00:00</pubDate><category>VB.NET</category></item><item><title>How to Create Microsoft Access DataSource for Win Forms App Visual Basic 2005</title><link>http://softlogger.com/7171/VB-NET/how-to-create-microsoft-access-datasource-for-win-forms-app-visual-basic-2005.aspx</link><description>&lt;FONT size=1&gt;Source Code: &lt;/FONT&gt;&lt;A href="http://www.getdotnetcode.com/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/AutobindDBToWinFormsApp_VB2005.htm"&gt;&lt;FONT size=1&gt;How to Create Microsoft Access DataSource for Win Forms App Visual Basic 2005&lt;/FONT&gt;&lt;/A&gt; 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;How to Create Microsoft Access DataSource for Win Forms App Visual Basic 2005&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;Visual Studio 2005 provides a feature, the 'Data Source Configuration Wizard', for creating a DataSource for a Windows Forms 2.0 application. This article provides step-by-step instructions and a sample Visual Basic 2005 application you can use to learn how make a Microsoft Access database the data source for a Visual Basic Windows Forms application.&lt;/P&gt;
&lt;P&gt;The 'Data Source Configuration Wizard' creates a DataSource component that can be used to bind controls on a Windows form to database objects such as tables, stored procedures, and views.&lt;/P&gt;
&lt;P&gt;This article will serve as 'step one' for future articles that will explain how to use a DataSource in a Windows Forms application.&amp;nbsp; It is a generic introduction for creating a Windows Forms DataSource using options and practices that are known to work in the majority of development scenarios. Once you understand the basics you should explore the different options you can take during some of the steps, to understand when and why you may want to deviate from the steps presented below.&lt;/P&gt;
&lt;P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;B&gt;Data Source Configuration Wizard&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;B&gt;Step-By-Step Instructions for Creating a DataSource&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; Create a Visual Basic 2005 Windows Forms application solution.&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; Add a Microsoft Access database file (.mdb), for example the Microsoft Northwind.mdb file, to the solution's 'Bin' folder.&lt;/P&gt;
&lt;P&gt;3.&amp;nbsp; From the Visual Studio menu select: Data -&amp;gt; Add New Data Source...&lt;/P&gt;
&lt;P&gt;&lt;IMG height=99 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/01AddNewDataSource.jpg" width=238 border=0&gt;&lt;/P&gt;
&lt;P&gt;4. The 'Data Source Configuration Wizard' will open. Select 'Database' and then click the 'Next&amp;gt;' button.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=338 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/02ChooseDataSource.jpg" width=431 border=0&gt;&lt;/P&gt;
&lt;P&gt;5. The 'Choose Your Data Source' step of the wizard will open. Click the 'New Connection..' button. &lt;/P&gt;
&lt;P&gt;&lt;IMG height=338 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/03ClickNewConnectionButton.jpg" width=431 border=0&gt;&lt;/P&gt;
&lt;P&gt;6. The 'Add Connection' dialog will open.&lt;/P&gt;
&lt;P&gt;Make sure the data source box reads: 'Microsoft Access Database File (OLE DB)'. If it does not, use the 'Change...' button to change the data source.&lt;/P&gt;
&lt;P&gt;Next, click the 'Browse..'. button. Use the 'Add Connection' dialog that opens to navigate to, and select, the Microsoft Access database you placed in your application's 'Bin' folder.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=362 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/04AddConnection.jpg" width=332 border=0&gt;&lt;/P&gt;
&lt;P&gt;7. The path to your database should now be shown in the database file name box. Click the 'Test Connection' button to make sure the connection works and then click the 'OK' button.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=362 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/05TestDatabaseConnection.jpg" width=332 border=0&gt;&lt;/P&gt;
&lt;P&gt;8. You will be returned to the 'Choose Your Data Source' step of the wizard. Click the 'Next&amp;gt;' button. &lt;/P&gt;
&lt;P&gt;&lt;IMG height=338 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/06ClickNextButton.jpg" width=431 border=0&gt;&lt;/P&gt;
&lt;P&gt;9. The 'Microsoft Visual Studio' dialog will open. This dialog asks if you would like to copy the file (database file) to your project. Click the 'Yes' button.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=119 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/07CopyFileToProject.jpg" width=610 border=0&gt;&lt;/P&gt;
&lt;P&gt;10. The 'Save the Connection String the Application Configuration File' step of the wizard opens. Change the name of the connection string if desired. Click the 'Next&amp;gt;' button.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=338 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/08SaveConnectionString.jpg" width=431 border=0&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;11. The 'Choose Your Database Objects' step of the wizard will open. Navigate the objects in your database using the tree view. Click checkbox(es) to select the database objects you desire to use in your Windows Forms application. After you have selected all the objects you desire to bind, click the 'Finish' button.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=338 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/09ChooseDBObjects.jpg" width=431 border=0&gt;&lt;/P&gt;
&lt;P&gt;12. The rest of the steps in these instructions are not part of the wizard. &lt;/P&gt;
&lt;P&gt;In this step you will set a property to control how Visual Studio uses the Microsoft Access database file each time you build your project.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;View the 'Solution Explorer' panel in your solution. Right-click the Microsoft Access database you added to the project and select: Properties&lt;/P&gt;
&lt;P&gt;The example below shows how to select the database properties for a database named 'Northwind'.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=474 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/10DataBaseCopyProperty.jpg" width=259 border=0&gt;&lt;/P&gt;
&lt;P&gt;13. The 'Properties' panel will open. In it set the 'Copy to Output Directory' property to: Copy if newer.&lt;/P&gt;
&lt;P&gt;&lt;IMG height=238 src="http://getdotnetco.web119.discountasp.net/nexDotNet/030017AutobindDBToWinFormsApp_VB2005/11CopyIfNewer.jpg" width=280 border=0&gt;&lt;/P&gt;&lt;img src ="http://blogs.vbcity.com/mcintyre/aggbug/8325.aspx" width = "1" height = "1" /&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=7171"&gt;</description><author>VB &amp;amp; .NET Blogs @ vbCity.com</author><pubDate>2007-05-26T00:00:00</pubDate><category>VB.NET</category></item><item><title>Closures in VB Part 3: Scope</title><link>http://softlogger.com/7168/VB-NET/closures-in-vb-part-3-scope.aspx</link><description>&lt;p&gt;For previous articles in this series please see&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/jaredpar/archive/2007/04/27/closures-in-vb-part-1.aspx"&gt;Part 1: Introduction&lt;/a&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/jaredpar/archive/2007/05/03/closures-in-vb-part-2-method-calls.aspx"&gt;Part 2: Method Calls&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Thus far in the series we've only lifted variables that are declared in the same block/scope.&amp;nbsp;What happens if we lift variables in different scope?&amp;nbsp; The answer is that one closure class will be created for every unique scope where a lifted variable is declared and all of the variables in that scope that are lifted will be placed in that closure.&amp;nbsp; Once again, examples speak best&lt;/p&gt;&lt;pre&gt;    &lt;span style="color: blue"&gt;Sub&lt;/span&gt; Scope1()
        &lt;span style="color: blue"&gt;Dim&lt;/span&gt; x = &lt;span style="color: maroon"&gt;5&lt;/span&gt;
        &lt;span style="color: blue"&gt;Dim&lt;/span&gt; f1 = &lt;span style="color: blue"&gt;Function&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal&lt;/span&gt; z &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;) x + z
        Console.WriteLine(f1(&lt;span style="color: maroon"&gt;5&lt;/span&gt;))
        &lt;span style="color: blue"&gt;If&lt;/span&gt; x &amp;gt; &lt;span style="color: maroon"&gt;2&lt;/span&gt; &lt;span style="color: blue"&gt;Then&lt;/span&gt;
            &lt;span style="color: blue"&gt;Dim&lt;/span&gt; y = &lt;span style="color: maroon"&gt;6&lt;/span&gt;
            &lt;span style="color: blue"&gt;Dim&lt;/span&gt; g = &lt;span style="color: maroon"&gt;7&lt;/span&gt;
            &lt;span style="color: blue"&gt;Dim&lt;/span&gt; f2 = &lt;span style="color: blue"&gt;Function&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal&lt;/span&gt; z &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;) z + y + g
            Console.WriteLine(f2(&lt;span style="color: maroon"&gt;4&lt;/span&gt;))
        &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;If&lt;/span&gt;
    &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;The code will end up looking like so ...&lt;/p&gt;&lt;pre&gt;    &lt;span style="color: blue"&gt;Class&lt;/span&gt; Closure1
        &lt;span style="color: blue"&gt;Public&lt;/span&gt; x &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;

        &lt;span style="color: blue"&gt;Function&lt;/span&gt; Lambda_f1(&lt;span style="color: blue"&gt;ByVal&lt;/span&gt; z &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;)
            &lt;span style="color: blue"&gt;Return&lt;/span&gt; x + z
        &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;Function&lt;/span&gt;

    &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;Class&lt;/span&gt;

    &lt;span style="color: blue"&gt;Class&lt;/span&gt; Closure2
        &lt;span style="color: blue"&gt;Public&lt;/span&gt; y &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;
        &lt;span style="color: blue"&gt;Public&lt;/span&gt; g &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;

        &lt;span style="color: blue"&gt;Function&lt;/span&gt; Lambda_f2(&lt;span style="color: blue"&gt;ByVal&lt;/span&gt; z &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;)
            &lt;span style="color: blue"&gt;Return&lt;/span&gt; y + z + g
        &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;Function&lt;/span&gt;
    &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;Class&lt;/span&gt;

    &lt;span style="color: blue"&gt;Sub&lt;/span&gt; Scope1()
        &lt;span style="color: blue"&gt;Dim&lt;/span&gt; c1 &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;New&lt;/span&gt; Closure1()
        c1.x = &lt;span style="color: maroon"&gt;5&lt;/span&gt;
        Console.WriteLine(c1.Lambda_f1(&lt;span style="color: maroon"&gt;5&lt;/span&gt;))
        &lt;span style="color: blue"&gt;If&lt;/span&gt; c1.x &amp;gt; &lt;span style="color: maroon"&gt;2&lt;/span&gt; &lt;span style="color: blue"&gt;Then&lt;/span&gt;
            &lt;span style="color: blue"&gt;Dim&lt;/span&gt; c2 &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;New&lt;/span&gt; Closure2()
            c2.y = &lt;span style="color: maroon"&gt;6&lt;/span&gt;
            c2.g = &lt;span style="color: maroon"&gt;7&lt;/span&gt;
            Console.WriteLine(c2.Lambda_f2(&lt;span style="color: maroon"&gt;4&lt;/span&gt;))
        &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;If&lt;/span&gt;
    &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;There are a couple of items to take away from this example.&amp;nbsp; &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Only two closure classes were created even though three variables were lifted.&amp;nbsp; The number of closures only depends on the number of scopes of all of the lifted declared variables. 
&lt;li&gt;The closures are created at the begining of the scope they are associated and not at the begining of the method.&amp;nbsp; This will be more important in the next part of the series.
&lt;li&gt;Each lambda instance is attached to the closure associated with the scope the lambda is declared in.&amp;nbsp; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;The next&amp;nbsp;twist is what were to happen if&amp;nbsp;the lambda "f2" were to also use the variable "x".&amp;nbsp; As it's currently written there is no association between Closure1 and Closure2 therefore&amp;nbsp;there is no way for it to access the lifted variable.&amp;nbsp; The answer is two fold.&amp;nbsp;&amp;nbsp;Firstly to&amp;nbsp;reduce clutter I pasted the closure classes as if they were separate entries.&amp;nbsp; In fact Closure2 would appear as a nested class of Closure1 in the real generated code.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Secondly if x were used inside of "f2", the real use would be "c1.x".&amp;nbsp; That's (almost) no different than "someOtherVar.x".&amp;nbsp; Therefore the instance of c1 will be lifted into Closure2.&amp;nbsp; &lt;/p&gt;&lt;pre&gt;&lt;span style="color: blue"&gt;Dim&lt;/span&gt; f2 = &lt;span style="color: blue"&gt;Function&lt;/span&gt;(&lt;span style="color: blue"&gt;ByVal&lt;/span&gt; z &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;) z + y + g + x&lt;/pre&gt;
&lt;p&gt;Woud result in the following definition of Closure2 ...&lt;/p&gt;&lt;pre&gt;    &lt;span style="color: blue"&gt;Class&lt;/span&gt; Closure2
        &lt;span style="color: blue"&gt;Public&lt;/span&gt; y &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;
        &lt;span style="color: blue"&gt;Public&lt;/span&gt; g &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;
        &lt;span style="color: blue"&gt;Public&lt;/span&gt; c1 &lt;span style="color: blue"&gt;As&lt;/span&gt; Closure1

        &lt;span style="color: blue"&gt;Function&lt;/span&gt; Lambda_f2(&lt;span style="color: blue"&gt;ByVal&lt;/span&gt; z &lt;span style="color: blue"&gt;As&lt;/span&gt; &lt;span style="color: blue"&gt;Integer&lt;/span&gt;)
            &lt;span style="color: blue"&gt;Return&lt;/span&gt; y + z + g + c1.x
        &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;Function&lt;/span&gt;
    &lt;span style="color: blue"&gt;End&lt;/span&gt; &lt;span style="color: blue"&gt;Class&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;In deeply nested lambdas and scopes this type of lifting will continue recursively.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;That's it for this entry, the next article will talk about looping structures and possibly variable lifetime.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2880594" width="1" height="1"&gt;&lt;img alt="via softlogger.com" src="http://softlogger.com/postview.aspx?ArticleID=7168"&gt;</description><author>jaredpars WebLog</author><pubDate>2007-05-25T00:00:00</pubDate><category>VB.NET</category></item><item><title>CheckedListBox (1) - Checking, Unchecking, Comparing</title><link>http://softlogger.com/7101/VB-NET/checkedlistbox-1--checking-unchecking-comparing.aspx</link><description>&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;FONT face=Verdana size=2&gt;This blog item was originally going to be about ten lines long and&amp;nbsp;all I intended to show was how to programatically uncheck all items in a CheckedListBox in VB 2005.&amp;nbsp; But, you know how it is, you think "Hmm, what about if ...?"&amp;nbsp; or "What if I ... ?" and before you know it, you've got a mini-article.&amp;nbsp; &amp;nbsp;So, before I forget why I started writing this item, here is the code needed to uncheck all items in a CheckedListBox:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;FONT face=Verdana color=#800080 size=2&gt;Programatically Uncheck All Items&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: #aaaaaa 1px solid; BORDER-TOP: #aaaaaa 1px solid; MARGIN-LEFT: 10pt; BORDER-LEFT: #aaaaaa 1px solid; MARGIN-RIGHT: 2pt; BORDER-BOTTOM: #aaaaaa 1px solid"&gt;
&lt;DIV style="FONT-SIZE: 10pt; BORDER-BOTTOM: #aaaaaa 1px solid"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/FONT&gt; i&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Integer&lt;/FONT&gt; = 0&lt;FONT color=#0000ff&gt; To&lt;/FONT&gt; CheckedListBox1.Items.Count - 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CheckedListBox1.SetItemChecked(i,&lt;FONT color=#0000ff&gt; False&lt;/FONT&gt;)&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;FONT face=Verdana size=2&gt;&amp;nbsp; It's one of those infuriatingly simple things (some might say "obvious") but it's only obvious&amp;nbsp;if you have already tracked down the answer and know about the SetItemChecked method.&amp;nbsp; It's a bit like Quiz questions - the only hard ones are those you don't know the answer to.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;&amp;nbsp;&amp;nbsp; Then I remembered that someone once asked about how to delete items that have been checked, so I thought I'd include that too.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#800080 size=2&gt;&lt;U&gt;Programatically Delete Checked Items&lt;/U&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face=Verdana color=#000000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: #aaaaaa 1px solid; BORDER-TOP: #aaaaaa 1px solid; MARGIN-LEFT: 10pt; BORDER-LEFT: #aaaaaa 1px solid; MARGIN-RIGHT: 2pt; BORDER-BOTTOM: #aaaaaa 1px solid"&gt;
&lt;DIV style="FONT-SIZE: 10pt; BORDER-BOTTOM: #aaaaaa 1px solid"&gt;&lt;B&gt;Code &lt;/B&gt;&lt;A onclick="window.clipboardData.setData('Text',this.parentNode.parentNode.childNodes[1].innerText);alert('Code copied to clipboard');" href="javascript:"&gt;Copy &lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="FONT-SIZE: 15px; OVERFLOW: auto; FONT-FAMILY: 'Courier New'; BACKGROUND-COLOR: #c5c5c5"&gt;&lt;FONT color=#0000ff&gt;With&lt;/FONT&gt; CheckedListBox1&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&lt;/FONT&gt; .CheckedItems.Count &amp;gt; 0&lt;FONT color=#0000ff&gt; Then&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/FONT&gt; x&lt;FONT color=#0000ff&gt; As&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; Integer&lt;/FONT&gt; = .CheckedItems.Count - 1&lt;FONT color=#0000ff&gt; To&lt;/FONT&gt; 0&lt;FONT color=#0000ff&gt; Step&lt;/FONT&gt; -1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Items.Remove(.CheckedItems(x))&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; If&lt;BR&gt;End&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; With&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;&amp