Main Menu
Knowledge Base
Product Registration
Log an Incident
Request a Feature
Search Incidents/Bug Reports


Search KB

Please note: In an effort to better serve you, we are in the process of restructuring DevCenter. In the process, we have moved many items that you may be used to finding in DevCenter over to the Main Site. If you are having trouble locating something, please try looking at the following places:

Knowledge Base Article: KB09979

HOWTO:Upgrading an existing application to use Application Styling


The information in this article applies to:
Application Styling (v6.2.20062)
  Article Created: 
7/5/2006

Last Updated:
7/10/2006

Article Type
How To
  
Page Options
Average Rating:
7 out of 10

Rate this page
Print this page
E-mail this page
Add to Favorites

Summary

This article will show how to take an existing NetAdvantage powered Windows Forms application and upgrade it to the 2006 Volume 2 version of NetAdvantage and how to enable support for Application Styling.

Additional Information

New in NetAdvantage 2006 Volume 2 is the support for Application Styling. This is a powerful new framework that allows for a great new way of applying visual themes to all user interface elements through the use of Infragistics Style Libraries. You can think of these as “Skins” for your application. In this article I will walk you through the steps that are needed in order for you to take an existing NetAdvantage equipped Windows Forms application and upgrade it to 2006 Volume 2 and enable Application Styling.

Before:



After:

Step-By-Step Example

First we will start off with a small sample application that was made using an older version of NetAdvantage. This sample is very simple and is solely used to demonstrate the upgrade process and then how to enable Application Styling.

Step 1: Upgrading to the latest NetAdvantage volume

The first thing we need to do is to update the assembly references so that they point to the NetAdvantage 2006 Volume 2 release. We do this by running the Project Upgrade Utility (found in Start/All Programs / Infragistics NetAdvantage 2006 Volume 2 / Project Upgrade Utility) and then loading up this sample into the utility. We then select the version that we will be upgrading to from the drop down listbox (select 2006 Volume 2 for either CLR 1X or CLR 2.0 as both will work). Click the Upgrade button and when it has completed, you can then open up the project and perform a rebuild. You can then run the application to make sure that it works. You can also look at the project references to make sure that the Infragistics 6.2 assemblies are referenced.

Step 2: Adding an Infragistics Style Library to the project

Once we are sure that the base application works fine, we can proceed to make the changes that will enable Application Styling.

First, we will add an Infragistics Style Library (known as an “isl” file) to our project so that it can be loaded by the application when it runs. The “isl” can be thought of as a skin that contains resources and settings that will be picked up by the Infragistics Windows Forms elements. You can use one of the included isl files that come with the 6.2 NetAdvantage installation located at:
C:\Program Files\Infragistics\NetAdvantage 2006 Volume 2 CLR 1.x\AppStylist\Styles\

In this example, we will be using “RadioFlyer.isl” as the Application Style to load. Simply copy and paste the file into the application’s BIN directory so that it will be available at runtime.

Step 2: Loading the Infragistics Style Library at runtime

We need to make a simple modification to our program’s entry point so that the isl gets loaded.

The one line of code that we will be using that must be placed before the Application.Run( ) method is:

C#

Infragistics.Win.AppStyling.StyleManager.Load(Application.StartupPath + @"\RadioFlyer.isl");

VB.NET

Infragistics.Win.AppStyling.StyleManager.Load(Application.StartupPath + "\RadioFlyer.isl")

Here is an example of this code in the working sample application:

C#

        [STAThread]
        static void Main()
        {
            Infragistics.Win.AppStyling.StyleManager.Load(
                Application.StartupPath + @"\RadioFlyer.isl");

            Application.Run(new Form1());
        }

VB.NET

    <STAThread()> Public Shared Sub Main()
        Infragistics.Win.AppStyling.StyleManager.Load( _
            Application.StartupPath + "\RadioFlyer.isl")

        Application.Run(New Form1)
    End Sub

Step 3: Run the application

All that is left to do is to run the application and see how the styles are applied to the various controls. You are now done.




Important note regarding VB.NET applications

By default, the application’s entry point is abstracted by VB.NET and the programmer does not get to see the code that starts up and runs the application (where in C# you do).

In order for you to control the Application’s startup, you will need to take these steps:

Step 1: Add the “Main” method

You will place this code either in a Class by itself or in your main form:

VB.NET

    <STAThread()> Public Shared Sub Main()

    End Sub

Note the STAThread attribute as well as the requirement to make this a “Shared” method. If you do not do this, you will get an error from visual studio stating that you do not have a method with the correct signature that can be used for Main.

Step 2: Add code to run the application

VB.NET

    <STAThread()> Public Shared Sub Main()
        Infragistics.Win.AppStyling.StyleManager.Load( _
            Application.StartupPath + "\RadioFlyer.isl")

        Application.Run(New Form1)
    End Sub

Now we can add the code to launch the application. You will basically create an instance of your main start up form and pass it into the Application.Run( ) Method. This will cause your form to load.

Step 3: Set the Startup object
Now that we have written the code, Visual Studio needs to be told to use this code as the program’s entry point as opposed to what it is using now by default. To configure this, right click on the project that contains the Sub Main and select Properties. Go to the “General” property settings and locate the “Startup Object” item and from its dropdown list, select “Sub Main”. Click on “Apply” / “OK” to save your settings. Your Sub Main will now be used as the program’s main entry point.


Review:

Now that you have read and understood this article, please download the included sample (in VB and C#) and practice this process against the sample. The samples include both the original project as well as the upgraded one. If you have any trouble, please compare the original to the upgraded and modified example to see what was missed.

Samples

appstyling_upgrade.zip
 Sample project for you to practice upgrading (C# and VB.NET versions)



How would you rate the quality of this content?
Poor -----------------------------------------> Outstanding

Tell us why you rated the content this way. (optional)