in

vbCity Blogs

New (temp) place for vbCity Blogs

Mike McIntyre's .NET Journal

August 2009 - Posts

  • Visual Basic 2010 Collection Initializers - Another Example

     I blogged about Visual Basic 2010 collection intializers in a previous blog here -> Collection Initializers

    Here's another example using an alternative syntax:

    Public Class Form1

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            '  Use a collection initializer to load a List(Of Customer)

            Dim customers = New List(Of Customer) From

                    {

                        New Customer("City Power & Light", "http://www.cpandl.com/"),

                        New Customer("Wide World Importers", "http://www.wideworldimporters.com/"),

                        New Customer("Lucerne Publishing", "http://www.lucernepublishing.com/")

                    }

        End Sub

    End Class

     

    Public Class Customer

        ' Use Visual Basic 2010 auto implemented properties.

        Public Property CompanyName As String

        Public Property Url As String

     

        Public Sub New(ByVal companyName, ByVal url)

            Me.CompanyName = companyName

            Me.Url = url

        End Sub

    End Class

     

  • Set ReportViewer Report and Linq DataSource Properties at Runtime

    When I looked for examples for setting a ReportViewer control's Report and Linq DataSource at runtime I found most included many more steps than necessary.

    Here's a short and sweet VB example

            ' Instantiate a DataContext that contains a table named "Activity"
            Dim appData As New AppDataDataContext
            ' Create a Linq query
            Dim query = From a In appData.Activities Select a
            ' Set the ReportViewer's ReportEmbeddedResource to the report to be shown in the ReportViewer
            ' Note: The BuidAction propery of the report was set to: EmbeddedResource
            Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "VBReportViewerExample.ActivityListReport.rdlc"
            ' Add a new ReportDataSource to the ReportViewer's DataSources.
            ' Note: the ToList method is called on the Linq query.
            Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Activity", query.ToList()))
            ' Call the ReportViewer's RefreshReport method to show the report.
            Me.ReportViewer1.RefreshReport()

    Here's a short and sweet C# example:

                // This examples is slightly different because it queries agains a stored procedure
                //    that requires begin date and end date arguments.
                DateTime? startDate = DateTime.Now.AddDays(-40);
                DateTime? endDate = DateTime.Now.AddDays(40);
                // Declare a linq query
                var x = from s in DB.VYDal.ScheduledEventsOnDate(startDate, endDate) orderby s.StartTime select s;
                // Set the ReportViewer's ReportEmbeddedResource to the report to be shown in the ReportViewer
                reportViewer1.LocalReport.ReportEmbeddedResource = "VinoSoft.Reports.Report1.rdlc";
                // Add a new ReportDataSource to the ReportViewer's DataSources.
                // Note: the ToList method is called on the Linq query.
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ScheduledEventsOnDateResult", x.ToList()));
                // Call the ReportViewer's RefreshReport method to show the report.
                reportViewer1.RefreshReport(); 

  • Microsoft Provides PHP Toolkit for ADO.NET Data Services

    The toolkit, for those of us who use PHP, makes it easier to use PHP to access ADO.NET Data Services, a set of features recently added to the .NET Framework. ADO.NET Data Services offer a simple way to expose any sort of data in a RESTful way. The PHP Toolkit for ADO.NET Data Services is an open source project funded by Microsoft and developed by Persistent Systems Ltd. and is available today on Codeplex: phpdataservices.codeplex.com

  • Using the Silverlight Grid on 5minute.com

     I think this is a good short video for learning the basics of using the Silverlight Grid in Microsoft Expression:

    Microsoft Blend Expression - Using Grids

  • Silverlight 3 - Get QueryString Values From a Silverlight Page

     Here's a function that retrieves a value from a pages query string; includes validation.

        Private Function GetQueryStringValue(ByVal key As String) As String

            ' Get the document's QueryString Dictionary

            Dim documentQueryString = CType(System.Windows.Browser.HtmlPage.Document.QueryString, System.Collections.Generic.Dictionary(Of String, String))

            ' Validate the key exits in the dictionary.

            If documentQueryString.ContainsKey(key) Then

                ' Return the value.

                Return documentQueryString(key).ToString

            Else

                ' Return a value representing no value found.

                Return "-1"

            End If

        End Function

     

  • Windows 7 Tip - Add Administrative Tools to All Programs and Start Menus

     Right-click the Windows 7 task bar and select Properties.

    Click the Customize button on the Properties dialog to open the Customize Start Menu dialog.

    Set System Administrative tool as shown in the image of the Customize Start Menu dialog shown below.

     

     

  • Windows 7 Golden Bits

    Being a Microsoft MSDN subscriber I was able to download the the final "golden" bits of Windows 7. 

    I upgraded one of my development computers from Vista Ultimate to Windows 7 Ultimate (x86).

    The computer is an AZUS C90OS with 2 GB RAM and a 150 GB hard drive.

    Before I started the upgrade I uninstalled Visual Studio 2010 Beta 1 and Microsoft.Net 4 Beta 1.  To learn why see Scott Hanselman's post:

     Vista Users - Uninstall Visual Studio 2010 Beta 1 before upgrading to Windows 7

    The upgrade ran without issues for about 2.5 hours.

    After the upgrade was completed I reinstalled Visual Studio 2010 Beta 1.

    I've been using the computer for about a day and half and I've found no problems with the software and drivers I use.

    Windows 7 feels solid to me - much like the way Windows XP felt when I first installed it.

    At this point I'm very happy with Windows 7.

    Windows 7 Tip - Change Size of Task Bar Icons

    One thing I changed almost immediately was the size of the icons in the new Windows task bar.

    Here is how: 

    Right-click the task bar and choose Properties.

    Check the 'Use small icons' check box.

  • Surprise!

     Last week I presented Visual Basic 2010 to 24 defense contract programmers who are using Visual Basic 2005.

    They were very pleased by what they saw and I can see why.

    In comparing 2005 with 2010 with the group it made me realize just how much Visual Basic.Net has improved. Looking back at 2005 was like taking a trip to the past.

    Have you checked out Visual Studio 2010 yet?  A well behaved Beta 1 is available at: Visual Studio 2010 Beta 1

     

Copyright 1998-2009 vbCity.com LLC
Powered by Community Server (Non-Commercial Edition), by Telligent Systems