<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://windowsclient.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Small Business Developer</title><subtitle type="html" /><id>http://windowsclient.net/blogs/wwade73/atom.aspx</id><link rel="alternate" type="text/html" href="http://windowsclient.net/blogs/wwade73/default.aspx" /><link rel="self" type="application/atom+xml" href="http://windowsclient.net/blogs/wwade73/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20416.853">Community Server</generator><updated>2008-10-07T14:01:00Z</updated><entry><title>Report Writing On The Cheap - Part 1</title><link rel="alternate" type="text/html" href="http://windowsclient.net/blogs/wwade73/archive/2009/01/29/report-writing-on-the-cheap-part-1.aspx" /><id>http://windowsclient.net/blogs/wwade73/archive/2009/01/29/report-writing-on-the-cheap-part-1.aspx</id><published>2009-01-29T18:40:00Z</published><updated>2009-01-29T18:40:00Z</updated><content type="html">&lt;p&gt;For many small business developers purchasing first-class reporting tools is unaffordable or not practical for simple reports.&amp;nbsp; One alternative is using Excel for reporting, but it requires dealing with COM+ objects and the assumption that the customer has Excel installed.&amp;nbsp; You could use SpreadsheetML, but it requires knowledge of XML, XSLT, Linq to XML, etc... and still depends on Excel or OpenOffice.&amp;nbsp; Another option is using the PrintForm component from the Visual Basic Power Packs, but it has limitations (I will do a separate post on using them).&amp;nbsp; The possibilities go one, but luckily, for those using .Net, Microsoft has the code for you to use.&amp;nbsp; The System.Drawing.Printing namespace along with GDI+ gives you the tools to make professional looking reports with a little bit of knowledge.&amp;nbsp; When I was looking for report tool alternatives, I happened across an article by Lee Falin (personal blog &lt;a title="http://leefalin.com/blog/" href="http://leefalin.com/blog/"&gt;http://leefalin.com/blog/&lt;/a&gt;) in Visual Studio Magazine (&lt;a href="http://www.visualstudiomagazine.com/"&gt;www.visualstudiomagazine.com&lt;/a&gt;), April 2005 (locator+ code VS0504GS_T).&amp;nbsp; In this article, Lee describes how to create a report from a datagrid using GDI+, and I hope everyone reading this blog will take the time to read his article.&amp;nbsp; With a little understanding you can create reports and not have to worry about 3rd-party software.&amp;nbsp; Understandable this is not very dynamic, but if you need that type of capability you should be looking at professional software.&amp;nbsp; What I want to do is expand on his article by going into more depth on the &lt;a href="http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx" target="_blank"&gt;PrintDocument class&lt;/a&gt; as well as other functionality.&amp;nbsp; I am going to break this down into multiple parts with part one focusing on the PrintDocument class and the events you need to handle to print a report.&amp;nbsp; So let us begin by looking at the PrintDocument class, it&amp;#39;s events, and what Microsoft suggests should happen during these events.&lt;/p&gt;
&lt;h4&gt;PrintDocument Class&lt;/h4&gt;
&lt;p&gt;The PrintDocument class is going to be the basic building block for our report.&amp;nbsp; Using the graphics object exposed from the PrintDocument events, we can create the document layout using text, images, and/or graphics just like you would on a Windows Form.&amp;nbsp; Lee Farlin, in his article, warns that since GDI+ uses unmanaged code, make sure you dispose of any drawing objects you create.&amp;nbsp; The suggested location is the EndPrint event.&amp;nbsp; You can add the PrintDocument as a component to your form or create it in the code behind.&amp;nbsp; In order for the document to be printed, you must handle the PrintDocument events.&amp;nbsp; &lt;/p&gt;
&lt;h4&gt;PrintDocument Events&amp;nbsp; &lt;/h4&gt;
&lt;p&gt;Below is the sequence of events with snippets to demonstrate how to use them.&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp; PrintDocument.Print method is initiated, starting the chain of events.&amp;nbsp; I created a simple windows project with one button.&amp;nbsp; The following code was added to the code behind.&amp;nbsp; &lt;/p&gt;&lt;pre class="code"&gt;&lt;font size="1"&gt;&lt;span style="COLOR:blue;"&gt;Private WithEvents &lt;/span&gt;myPrintDoc &lt;span style="COLOR:blue;"&gt;As New &lt;/span&gt;PrintDocument 
&lt;span style="COLOR:blue;"&gt;Private Sub &lt;/span&gt;Button1_Click(&lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;sender &lt;span style="COLOR:blue;"&gt;As &lt;/span&gt;System.Object, _
                          &lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;e &lt;span style="COLOR:blue;"&gt;As &lt;/span&gt;System.EventArgs) &lt;span style="COLOR:blue;"&gt;Handles &lt;/span&gt;Button1.Click
    myPrintDoc.Print()
&lt;span style="COLOR:blue;"&gt;End Sub&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;2.&amp;nbsp; As soon as the Print method is executed, the BeginPrint event is raised.&amp;nbsp; Here you can deal with setting up resources that will be used for the print job.&amp;nbsp; So you would do things such as initialize fonts, load data, or run validations before the printing process begins.&amp;nbsp; One example would be to ensure that there are rows in the dataset you are going to use to print.&amp;nbsp; In that case you could set e.Cancel = true to end the print job if the dataset was empty or had errors.&lt;/p&gt;&lt;pre class="code"&gt;&lt;font size="1"&gt;&lt;span style="COLOR:blue;"&gt;Private WithEvents &lt;/span&gt;myPrintDoc &lt;span style="COLOR:blue;"&gt;As New &lt;/span&gt;PrintDocument 
&lt;span style="COLOR:blue;"&gt;Private Sub &lt;/span&gt;myPrintDoc_BeginPrint(&lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;sender &lt;span style="COLOR:blue;"&gt;As Object&lt;/span&gt;, _
                                  &lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;e &lt;span style="COLOR:blue;"&gt;As &lt;/span&gt;System.Drawing.Printing.PrintEventArgs) _
                                  &lt;span style="COLOR:blue;"&gt;Handles &lt;/span&gt;myPrintDoc.BeginPrint
    &lt;span style="COLOR:blue;"&gt;If &lt;/span&gt;myDataSet.HasErrors &lt;span style="COLOR:blue;"&gt;Or &lt;/span&gt;myDataSet.Tables(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;MyTable&amp;quot;&lt;/span&gt;).Rows.Count &amp;lt; 1 &lt;/font&gt;&lt;font size="1"&gt;&lt;span style="COLOR:blue;"&gt;Then
        &lt;/span&gt;e.Cancel = &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;&lt;font size="1"&gt;True
    End If

End Sub&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;3.&amp;nbsp; Next, before each page is printed, the QueryPageSettings event is raised and you can use the event to adjust the page settings for the page you are about to print.&amp;nbsp; This means that each page could use different settings and all you would have to do is modify the QueryPageSettingsEventArgs object, using the PageSettings property.&amp;nbsp; You also have access to a cancel property to cancel the print job.&amp;nbsp; The below example sets the first page of the report to be printed as landscape.&lt;/p&gt;&lt;pre class="code"&gt;&lt;font size="1"&gt;&lt;span style="COLOR:blue;"&gt;Private &lt;/span&gt;currentPageCount &lt;/font&gt;&lt;font size="1"&gt;&lt;span style="COLOR:blue;"&gt;As Integer
Private Sub &lt;/span&gt;myPrintDoc_QueryPageSettings(&lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;sender &lt;span style="COLOR:blue;"&gt;As Object&lt;/span&gt;, _
                        &lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;e &lt;span style="COLOR:blue;"&gt;As &lt;/span&gt;System.Drawing.Printing.QueryPageSettingsEventArgs) _
                        &lt;span style="COLOR:blue;"&gt;Handles &lt;/span&gt;myPrintDoc.QueryPageSettings
    &lt;span style="COLOR:blue;"&gt;If &lt;/span&gt;currentPageCount = 1 &lt;span style="COLOR:blue;"&gt;Then &lt;/span&gt;e.PageSettings.Landscape = &lt;/font&gt;&lt;span style="COLOR:blue;"&gt;&lt;font size="1"&gt;True
End Sub&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;4.&amp;nbsp; After QueryPageSettings, PrintPage is raised.&amp;nbsp; Here is where the majority of the work is done.&amp;nbsp; The event exposes a graphics object, which you can use to draw lines, text, bitmaps, etc... on the page. To allow printing over multiple pages you need to set the HasMorePages (default is false) property to true, which will call this event again (QueryPageSettings is also called).&amp;nbsp; Keep in mind that you will need to set this back to false, otherwise the PrintPage event will keep being raised.&amp;nbsp; Like the other events you can still cancel the print job by setting e.Cancel = True.&amp;nbsp; Additional properties of interest are MarginBounds, which gets the rectangular area inside the margins.&amp;nbsp; The PageBounds property gets the rectangular area for the whole page.&amp;nbsp; Finally, PageSettings gets the current page&amp;#39;s settings.&amp;nbsp; The image below shows the bounds property rectangles as well as a sample PrintPage event code to write a line of text.&amp;nbsp; You can see the effect of writing the string at position 0,0, which has no concept of the page bounds, and this will be something you will need to handle in your code.&lt;/p&gt;&lt;pre class="code"&gt;&lt;font size="1"&gt;&lt;span style="COLOR:blue;"&gt;Private Sub &lt;/span&gt;myPrintDoc_PrintPage(&lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;sender &lt;span style="COLOR:blue;"&gt;As Object&lt;/span&gt;, _
                                 &lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;e &lt;span style="COLOR:blue;"&gt;As &lt;/span&gt;System.Drawing.Printing.PrintPageEventArgs) _
                                 &lt;span style="COLOR:blue;"&gt;Handles &lt;/span&gt;myPrintDoc.PrintPage
    e.Graphics.DrawString(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Hello World Printing&amp;quot;&lt;/span&gt;, &lt;span style="COLOR:blue;"&gt;New &lt;/span&gt;Font(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Arial&amp;quot;&lt;/span&gt;, 12, _
              FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, 0, 0)
&lt;span style="COLOR:blue;"&gt;End Sub&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/ReportWritingOnTheCheapPart1_EF29/image_2.png"&gt;&lt;img style="BORDER-TOP-WIDTH:0px;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="395" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/ReportWritingOnTheCheapPart1_EF29/image_thumb.png" width="509" border="0" /&gt;&lt;/a&gt; &lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;
&lt;p&gt;5.&amp;nbsp; Finally, after all pages have been printed, EndPrint is executed.&amp;nbsp; Like BeginPrint which you can use to initialize fonts, file streams, resources, in EndPrint you would close dispose of those objects.&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;h4&gt;Conclusion&lt;/h4&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With this basic understanding of the PrintDocument, we can now move to creating a document layout using GDI+ and the above events.&amp;nbsp; Hopefully, this gets you interested in what can be achieved using the PrintDocument class.&amp;nbsp; Part two will focus on how to add text, images, graphics, as well a few tips on handling text (word wrap, multiple pages, print a textfile, etc...).&amp;nbsp; As always comments are welcome and would be helpfully if you want me to dig deeper into a specific topic.&lt;/p&gt;&lt;img src="http://windowsclient.net/aggbug.aspx?PostID=103380" width="1" height="1"&gt;</content><author><name>wwade73</name><uri>http://windowsclient.net/members/wwade73.aspx</uri></author></entry><entry><title>XML and Strongly-Typed Datasets - Part 3</title><link rel="alternate" type="text/html" href="http://windowsclient.net/blogs/wwade73/archive/2008/12/26/xml-and-strongly-typed-datasets-part-3.aspx" /><id>http://windowsclient.net/blogs/wwade73/archive/2008/12/26/xml-and-strongly-typed-datasets-part-3.aspx</id><published>2008-12-26T21:00:04Z</published><updated>2008-12-26T21:00:04Z</updated><content type="html">&lt;p&gt;I apologize for how late this post is, but Christmas snuck up on me and I had to rush to meet all the family obligations.&amp;#160; In this post I want to look at using more complex XML files which have parent-child relationships as well as how to validate XML files.&amp;#160; Another customer of mine wanted code to fill a dataset with data from XML, but also needed to enforce some rules.&amp;#160; I used code to validate the document due to a few factors outside my control, but I like to see if there would have been a better way to do this.&amp;#160; So now I have the opportunity to replicate the problem and hopefully do a better job solving it.&amp;#160; As always input is welcome if you have a better way to do this.&amp;#160; Otherwise let us begin.&lt;/p&gt;  &lt;h5&gt;Setup&lt;/h5&gt;  &lt;p&gt;Before we being you will need to get a few files from Microsoft.&amp;#160; The XML file, CustomerOrders.xml, is located here - &lt;a title="http://msdn.microsoft.com/en-us/library/bb387025.aspx" href="http://msdn.microsoft.com/en-us/library/bb387025.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb387025.aspx&lt;/a&gt;.&amp;#160; Next, create a new windows forms application, adding the XML file to the project.&amp;#160; If you read my last blog post, you know all you need to do is use the XML-to-Schema tool and it will generate the needed xsd file.&amp;#160; After that, set the custom tool property of the xsd file to MSDatasetGenerator.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart3_E0FC/image_2.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="145" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart3_E0FC/image_thumb.png" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After that right click on the xsd file in the solution explorer and select &amp;quot;Run Custom Tool.&amp;quot;&amp;#160; A new datasource will now show up in the Data Sources tab.&amp;#160; I need to make one change to the dataset since I want to show customers and their orders (the relationship was not automatically made).&amp;#160; Right click on the dataset and select &amp;quot;Open With...&amp;quot;&amp;#160; From there right click on the design surface and select &amp;quot;Add&amp;gt;Relation...&amp;quot;&amp;#160; Set the relationship like the image below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart3_E0FC/image_4.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="318" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart3_E0FC/image_thumb_1.png" width="531" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;A one-to-many relationship will be created.&amp;#160;&amp;#160; you can now drag items from the Data Sources tab onto the form and modify the look during design time.&amp;#160; Select the &amp;quot;Copy to Output Directory&amp;quot; property and set it to &amp;quot;Copy Always.&amp;quot;&amp;#160; I am only doing this for brevity sake, you would be better off to set a configurable location in the app.config file to better handle this.&lt;/p&gt;  &lt;h5&gt;Create the UI&lt;/h5&gt;  &lt;p&gt;&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart3_E0FC/image_6.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="356" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart3_E0FC/image_thumb_2.png" width="537" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I created the UI by dragging the Customer table (select Details, not DataGridView) from the Data Sources tab onto the form.&amp;#160; This creates the CustomerBindingNavigator as well as the labels and textboxes.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart3_E0FC/image_8.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="244" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart3_E0FC/image_thumb_3.png" width="224" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The Customer_Id and Customers_Id fields were removed, since I didn&amp;#39;t want to display them.&amp;#160; Next, I dragged the Order table that is below the Customer Table in the drop down list and dragged it onto the form.&amp;#160; A datagridview will be created for the Order table which includes the code to display the correct orders when the parent customer is selected.&lt;/p&gt;  &lt;h5&gt; Validation&lt;/h5&gt;  &lt;p&gt;Double click on the form and add the following code:&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color:blue;"&gt;Imports &lt;/span&gt;System.Xml
&lt;span style="color:blue;"&gt;Imports &lt;/span&gt;System.Xml.Schema

&lt;span style="color:green;"&gt;&amp;#39;The validation code is from the MSDN website - http://msdn.microsoft.com/en-us/library/bb387037.aspx
&amp;#39;so all credit belongs to them.

&lt;/span&gt;&lt;span style="color:blue;"&gt;Public Class &lt;/span&gt;Form1

    &lt;span style="color:blue;"&gt;Dim &lt;/span&gt;errors &lt;span style="color:blue;"&gt;As Boolean &lt;/span&gt;= &lt;span style="color:blue;"&gt;False &lt;/span&gt;&lt;span style="color:green;"&gt;&amp;#39;Holds validation state for the XDocument

    &amp;#39;Capture the XSD error event to show what caused the failue
    &lt;/span&gt;&lt;span style="color:blue;"&gt;Private Sub &lt;/span&gt;XSDErrors(&lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;o &lt;span style="color:blue;"&gt;As Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;e &lt;span style="color:blue;"&gt;As &lt;/span&gt;ValidationEventArgs)
        MessageBox.Show(&lt;span style="color:blue;"&gt;String&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot;{0}&amp;quot;&lt;/span&gt;, e.Message))
        errors = &lt;span style="color:blue;"&gt;True
    End Sub

    Private Sub &lt;/span&gt;Form1_Load(&lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;sender &lt;span style="color:blue;"&gt;As Object&lt;/span&gt;, &lt;span style="color:blue;"&gt;ByVal &lt;/span&gt;e &lt;span style="color:blue;"&gt;As &lt;/span&gt;System.EventArgs) &lt;span style="color:blue;"&gt;Handles Me&lt;/span&gt;.Load

        &lt;span style="color:green;"&gt;&amp;#39;Load the schema
        &lt;/span&gt;&lt;span style="color:blue;"&gt;Dim &lt;/span&gt;schemas &lt;span style="color:blue;"&gt;As &lt;/span&gt;XmlSchemaSet = &lt;span style="color:blue;"&gt;New &lt;/span&gt;XmlSchemaSet()
        schemas.Add(&lt;span style="color:#a31515;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;CustomersOrders.xsd&amp;quot;&lt;/span&gt;) &lt;span style="color:green;"&gt;&amp;#39;There is no namespace on the xml, so use blank for the first parameter

        &amp;#39;Load the xml
        &lt;/span&gt;&lt;span style="color:blue;"&gt;Dim &lt;/span&gt;custOrdDoc &lt;span style="color:blue;"&gt;As &lt;/span&gt;XDocument = XDocument.Load(&lt;span style="color:#a31515;"&gt;&amp;quot;CustomersOrders.xml&amp;quot;&lt;/span&gt;)

        &lt;span style="color:green;"&gt;&amp;#39;Initialize the error flag
        &lt;/span&gt;errors = &lt;span style="color:blue;"&gt;False

        &lt;/span&gt;&lt;span style="color:green;"&gt;&amp;#39;Validate the xdocument with the schema
        &lt;/span&gt;custOrdDoc.Validate(schemas, &lt;span style="color:blue;"&gt;AddressOf &lt;/span&gt;XSDErrors)

        MessageBox.Show(&lt;span style="color:blue;"&gt;String&lt;/span&gt;.Format(&lt;span style="color:#a31515;"&gt;&amp;quot;custOrdDoc {0}&amp;quot;&lt;/span&gt;, IIf(errors, &lt;span style="color:#a31515;"&gt;&amp;quot;did not validate&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;validated&amp;quot;&lt;/span&gt;)))

        &lt;span style="color:blue;"&gt;If &lt;/span&gt;errors = &lt;span style="color:blue;"&gt;False Then
            &lt;/span&gt;&lt;span style="color:green;"&gt;&amp;#39;Fill the stronly-typed dataset if successful.
            &lt;/span&gt;Root.ReadXml(custOrdDoc.CreateReader)
        &lt;span style="color:blue;"&gt;End If

    End Sub

End Class
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now when you run program it will display the validation status and then display the results.&amp;#160; The UI isn&amp;#39;t that exciting, but the ability to create a UI during design time rather than run time as well as validate the loaded XML makes working with XML just that much easier.&amp;#160; Combine this with VB 9&amp;#39;s ability to use XML literals and LinqToXML, you have some powerful tools to work with XML in .Net.&lt;/p&gt;&lt;img src="http://windowsclient.net/aggbug.aspx?PostID=94468" width="1" height="1"&gt;</content><author><name>wwade73</name><uri>http://windowsclient.net/members/wwade73.aspx</uri></author></entry><entry><title>XML and Strongly-Typed Datasets - Part 2</title><link rel="alternate" type="text/html" href="http://windowsclient.net/blogs/wwade73/archive/2008/11/18/xml-and-strongly-typed-datasets-part-2.aspx" /><id>http://windowsclient.net/blogs/wwade73/archive/2008/11/18/xml-and-strongly-typed-datasets-part-2.aspx</id><published>2008-11-18T21:09:00Z</published><updated>2008-11-18T21:09:00Z</updated><content type="html">&lt;p&gt;I did a bit of research and found another way to allow design-time usage of an XML file.&amp;nbsp; This one has a few more steps than my previous post, but I think it is more useful.&amp;nbsp; I am going to provide a simple example in this post, but will follow it up with a more complex example.&amp;nbsp; You will need the &lt;strike&gt;Visual Basic Power Pack &lt;/strike&gt;XML to Schema tool installed, which you can download from here - &lt;a href="http://msdn.microsoft.com/en-us/vbasic/bb840042.aspx"&gt;http://msdn.microsoft.com/en-us/vbasic/bb840042.aspx&lt;/a&gt;.&amp;nbsp; Hopefully this walkthrough will be helpful.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new windows project in VB 2008.&lt;/li&gt;
&lt;li&gt;Add a new xml file, call it books.xml.&amp;nbsp; When you see the xml designer you can replace the code with the books.xml code from here - &lt;a title="http://msdn.microsoft.com/en-us/library/ms762271.aspx" href="http://msdn.microsoft.com/en-us/library/ms762271.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms762271.aspx&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Set the Copy To Output Directory to &amp;quot;Copy Always&amp;quot; for this example.&lt;/li&gt;
&lt;li&gt;Now add another new file and select the XML to Schema template.&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_6.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="257" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_thumb_2.png" width="425" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;I called the file BooksSchema.xsd and then click add.&amp;nbsp; Another screen will pop up, click on Add from File.&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_8.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="285" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_thumb_3.png" width="426" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Select the books.xml file you created and click ok.&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_10.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="285" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_thumb_4.png" width="428" border="0" /&gt;&lt;/a&gt;&amp;nbsp; &lt;/li&gt;
&lt;li&gt;Click Ok again.&lt;/li&gt;
&lt;li&gt;Now, you can click on the Data Sources Tab and it will show the catalog dataset.&amp;nbsp; Drag the Books icon onto the form design surface and it will automatically create a datagridview with the columns from the XML file.&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_12.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="289" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_thumb_5.png" width="428" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Now go the code behind and add this line of code to the Load event.&lt;/li&gt;
&lt;p&gt;&lt;span style="COLOR:blue;"&gt;Private Sub &lt;/span&gt;Form1_Load(&lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;sender &lt;span style="COLOR:blue;"&gt;As Object&lt;/span&gt;, &lt;span style="COLOR:blue;"&gt;ByVal &lt;/span&gt;e &lt;span style="COLOR:blue;"&gt;As &lt;/span&gt;System.EventArgs)&lt;span style="COLOR:blue;"&gt;&amp;nbsp; _ Handles Me&lt;/span&gt;.Load &lt;/p&gt;
&lt;p&gt;Catalog.ReadXml(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;Books.xml&amp;quot;&lt;/span&gt;) &lt;/p&gt;
&lt;p&gt;&lt;span style="COLOR:blue;"&gt;End Sub&lt;/span&gt;&lt;/p&gt;
&lt;li&gt;In the end it should look like this:&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_14.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="303" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_thumb_6.png" width="424" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Now, if you want to view the schema like you do a dataset, you need to right click on the schema and select Open with... and select Dataset Editor from the list.&amp;nbsp; Click OK.&amp;nbsp; A warning will come up, but click yes.&amp;nbsp; Now you will see the XML schema like you do a regular dataset. &lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_16.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="124" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLandStronglyTypedDatasetsPart2_E337/image_thumb_7.png" width="168" align="left" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Next week, I will use an example where there are relationships in the XML and use that to create multiple datagridviews with a parent-child relationship.&lt;/p&gt;&lt;img src="http://windowsclient.net/aggbug.aspx?PostID=82932" width="1" height="1"&gt;</content><author><name>wwade73</name><uri>http://windowsclient.net/members/wwade73.aspx</uri></author></entry><entry><title>XML And Strongly-Typed Datasets</title><link rel="alternate" type="text/html" href="http://windowsclient.net/blogs/wwade73/archive/2008/10/22/xml-and-strongly-typed-datasets.aspx" /><id>http://windowsclient.net/blogs/wwade73/archive/2008/10/22/xml-and-strongly-typed-datasets.aspx</id><published>2008-10-22T12:55:00Z</published><updated>2008-10-22T12:55:00Z</updated><content type="html">&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is another interesting item I ran into from the field.&amp;nbsp; A customer wants to use XML with a DataGridView, but the issue is that they want to manipulate the look of the data in the datagridview during design time.&amp;nbsp; My solution was to create a strongly-typed dataset and then read the xml into the dataset.&amp;nbsp; I need to give credit to Rong-Chun Zhang on the MSDN Forums for helping me solve this problem.&amp;nbsp; Here is the link to the topic at MSDN - &lt;a title="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3543590&amp;amp;SiteID=1" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3543590&amp;amp;SiteID=1"&gt;http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3543590&amp;amp;SiteID=1&lt;/a&gt;&amp;nbsp; The created project is nothing more than a simple Windows Forms Project.&lt;/p&gt;
&lt;h5&gt;Source XML&lt;/h5&gt;
&lt;p&gt;Here is the XML file I used (same as the one from the forum topic)&lt;/p&gt;
&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;MyDataSet&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;MyDataSetnamespace&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Order_Details&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;OrderID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;10248&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;OrderID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ProductID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;11&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ProductID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UnitPrice&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;14.0000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UnitPrice&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Quantity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;12&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Quantity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Discount&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Discount&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Order_Details&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Order_Details&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;OrderID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;10249&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;OrderID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ProductID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;11&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ProductID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UnitPrice&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;14.0000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UnitPrice&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Quantity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;12&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Quantity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Discount&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Discount&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Order_Details&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Order_Details&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;OrderID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;10250&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;OrderID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ProductID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;11&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ProductID&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UnitPrice&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;14.0000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UnitPrice&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Quantity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;12&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Quantity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Discount&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;0&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Discount&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Order_Details&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;MyDataSet&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h5&gt;&lt;/h5&gt;
&lt;h5&gt;Strongly-Typed Dataset&lt;/h5&gt;
&lt;p&gt;Next, you need to create a strongly typed dataset.&amp;nbsp; What you need to do is add a new item to your project and then select dataset.&amp;nbsp; Give the dataset a meaningful name and click Add.&amp;nbsp; This will bring you to the dataset designer.&amp;nbsp; From there you can add a datatable and all the associated columns.&amp;nbsp; Here is the result that I had:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLAndStronglyTypedDatasets_EADF/image_2.png"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="150" alt="image" src="http://windowsclient.net/blogs/wwade73/WindowsLiveWriter/XMLAndStronglyTypedDatasets_EADF/image_thumb.png" width="176" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I saved the changes and now the dataset shows up in the Data Sources Tab.&amp;nbsp; Now you can add it to your form and manipulate it as you would any other databound datagridview control.&lt;/p&gt;
&lt;h5&gt;Code Behind&lt;/h5&gt;
&lt;p&gt;Finally, you need to load the XML into the dataset.&amp;nbsp; The code is as follows:&lt;/p&gt;
&lt;p&gt;&lt;span style="COLOR:blue;"&gt;Try &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR:green;"&gt;&amp;#39;You need to set the namespace on the dataset to match the one on the &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;xml file. &lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;MyDataSet1.Namespace = &lt;span style="COLOR:#a31515;"&gt;&amp;quot;MyDataSetnamespace&amp;quot; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;MyDataSet1.ReadXml(txtXMLFileLocation.Text) &lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR:blue;"&gt;Catch &lt;/span&gt;ex &lt;span style="COLOR:blue;"&gt;As &lt;/span&gt;Exception &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show(ex.Message) &lt;br /&gt;&lt;span style="COLOR:blue;"&gt;End Try&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This post was really simplistic, but I am going to do more research into how to use more complex XML files with the datagridview, assuming there is any interest.&amp;nbsp; &lt;/p&gt;&lt;img src="http://windowsclient.net/aggbug.aspx?PostID=74885" width="1" height="1"&gt;</content><author><name>wwade73</name><uri>http://windowsclient.net/members/wwade73.aspx</uri></author></entry><entry><title>Microsoft Small Business Developer Links</title><link rel="alternate" type="text/html" href="http://windowsclient.net/blogs/wwade73/archive/2008/10/07/microsoft-small-business-developer-links.aspx" /><id>http://windowsclient.net/blogs/wwade73/archive/2008/10/07/microsoft-small-business-developer-links.aspx</id><published>2008-10-07T19:15:00Z</published><updated>2008-10-07T19:15:00Z</updated><content type="html">&lt;font face="Times New Roman" size="3"&gt;
&lt;p&gt;To get things started I figured I would include a few links to Microsoft’s Small Business Developer website.&amp;nbsp; The information is good, though I think it only gives you a taste of what you can do.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-ca/smallbusiness/default.aspx"&gt;Small Business Developer Website&lt;/a&gt;&lt;br /&gt;&lt;a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1812&amp;amp;SiteID=1"&gt;Small Business Developer Forum&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Happy Hunting.&lt;/p&gt;&lt;/font&gt;&lt;img src="http://windowsclient.net/aggbug.aspx?PostID=70118" width="1" height="1"&gt;</content><author><name>wwade73</name><uri>http://windowsclient.net/members/wwade73.aspx</uri></author></entry><entry><title>Reason To Blog</title><link rel="alternate" type="text/html" href="http://windowsclient.net/blogs/wwade73/archive/2008/10/07/reason-to-blog.aspx" /><id>http://windowsclient.net/blogs/wwade73/archive/2008/10/07/reason-to-blog.aspx</id><published>2008-10-07T19:12:00Z</published><updated>2008-10-07T19:12:00Z</updated><content type="html">&lt;p&gt;Welcome.&amp;nbsp; This is my first attempt at blogging, so bear with me.&amp;nbsp; What I hope to accomplish is to post code and tips for the small business developer.&amp;nbsp; Personally, I love the idea of working&amp;nbsp;with small businesses to fulfil their software needs.&amp;nbsp;&amp;nbsp;They aren’t loaded with money, so as a developer you need to find unique ways to build software that fits their needs and budget.&amp;nbsp; A good example is report writing.&amp;nbsp; Typically, a business will use Excel or Access to display their data.&amp;nbsp; That might be ok now, but there are limitations to what it can do.&amp;nbsp; Coding is done using VBA, which is a bit old and tired.&amp;nbsp; An alternative would be to write any business logic in VB.Net/C# and have it output the data into XML (e.g. SpreadSheetML for Excel) for Office 2003/2007, earlier versions will need to use Office Automation.&amp;nbsp; From there the user can open the data in Excel and manipulate it as they normally do, but the code is done using the latest technology.&amp;nbsp; So, there are a lot of possibilities.&amp;nbsp; I hope this will be a useful outlet and all constructive criticism is welcome.&lt;/p&gt;&lt;img src="http://windowsclient.net/aggbug.aspx?PostID=70117" width="1" height="1"&gt;</content><author><name>wwade73</name><uri>http://windowsclient.net/members/wwade73.aspx</uri></author></entry><entry><title>Format Data Bound Textboxes as Currency</title><link rel="alternate" type="text/html" href="http://windowsclient.net/blogs/wwade73/archive/2008/10/07/format-data-bound-textboxes-as-currency.aspx" /><id>http://windowsclient.net/blogs/wwade73/archive/2008/10/07/format-data-bound-textboxes-as-currency.aspx</id><published>2008-10-07T18:01:00Z</published><updated>2008-10-07T18:01:00Z</updated><content type="html">&lt;p&gt;Recently, I ran into an issue where a customer wanted to display currencies in data bound textboxes, but there didn’t seem to be an easy way to do this.&amp;nbsp; Luckily, I found the information in the MSDN forums and I figured I would create a simple project to bring together a bunch of threads on the subject.&amp;nbsp; Here is the source code - &lt;a class="" href="http://blogs.windowsclient.net/blogs/wwade73/databindingcurrency.zip"&gt;Source Code&lt;/a&gt; . &lt;/p&gt;
&lt;p&gt;So assuming you already have bound textboxes, here are three approaches I have found to deal with this issue.&lt;/p&gt;
&lt;p&gt;1. &lt;u&gt;Set the bindings through code&lt;/u&gt;&amp;nbsp; In this case you set up the binding through code and now you need to modify it to display the data as a currency.&amp;nbsp; Here is the code I used:&lt;/p&gt;
&lt;p&gt;‘Formatting codes found at MSDN - Standard Numeric Format Strings http://msdn.microsoft.com/en-us/library/aa720653.aspx&lt;/p&gt;
&lt;p&gt;Me.TextBox4.DataBindings.Add(“text”, PriceBindingSource, “Price”, True, DataSourceUpdateMode.OnPropertyChanged, ” “, “C”)&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp; &lt;u&gt;Format the field during an event&lt;/u&gt;&amp;nbsp; I used the textchanged event, but how you do this is really based on the behavior you want.&lt;/p&gt;
&lt;p&gt;Private Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.TextChangedMe.TextBox2.Text = FormatCurrency(Me.TextBox2.Text, 2)End Sub&lt;/p&gt;
&lt;p&gt;3.&amp;nbsp; &lt;u&gt;Use Visual Studio Wizard&lt;/u&gt;&amp;nbsp; Finally, you can use the Visual Studio IDE to set the bindings.&amp;nbsp; What you need to do is select the textbox and expand the (DataBindings) property.&amp;nbsp; Select the Advanced Binding field and then click on the button that appears in the field.&amp;nbsp; A window will pop up and from there you can set the formatting for the textbox.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img title="VS advanced tab" style="WIDTH:562px;HEIGHT:342px;" height="499" alt="VS advanced tab" src="http://blogs.windowsclient.net/blogs/wwade73/advancetab.png" width="698" align="middle" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://wade.thecoderblogs.com/files/2008/09/advancetab.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Hopefully this tidbit helps&lt;/p&gt;&lt;img src="http://windowsclient.net/aggbug.aspx?PostID=70085" width="1" height="1"&gt;</content><author><name>wwade73</name><uri>http://windowsclient.net/members/wwade73.aspx</uri></author></entry></feed>