Getting Started

  • 3 min to read
Important

You need a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

Perform the steps below to get started with the Unit Conversion API.

  1. Start Microsoft Visual Studio and create a new Windows Forms App (.NET Framework) project.

  2. Right-click the References node in the Solution Explorer and select Add Reference. In the invoked Reference Manager dialog, add a reference to the DevExpress.Docs.v19.2.dll assembly.

  3. Drop a Button from the Toolbox onto the form.

  4. Double click the button. Add the following code to the button's Click event handler.

    using DevExpress.UnitConversion;
    //...
    // The height is 5'4".
    QuantityValue<Distance> height = (5.0).Feet() + (4.0).Inches();
    string s = String.Format("The height is {0} ells or {1} meters.",
        height.ToElls().Value.ToString("g3"), height.ToMeters().Value.ToString("g3"));
    MessageBox.Show(s);
    
  5. Run the project and click the button.

    units_getstarted

  1. Start Microsoft Visual Studio and create a new Console Application (.NET Core) project.

  2. Install the DevExpress.Document.Processor NuGet package.

  3. Paste the code below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    using DevExpress.UnitConversion;
    // ...
    
    QuantityValue<Distance> height = (5.0).Feet() + (4.0).Inches();
    string s = String.Format("The height is {0} ells or {1} meters.",
    height.ToElls().Value.ToString("g3"), height.ToMeters().Value.ToString("g3"));
    Console.WriteLine(s);
    
  4. Run the project.

    result

  1. Start Microsoft Visual Studio and create a new Console Application (.NET Core) project.

  2. Install the DevExpress.WindowsDesktop.Document.Processor NuGet package.

  3. Right-click the project in the Solution Explorer and select Edit Project File.

    Office_NetCore_3_Edit_Project_File

    Change the project's SDK attribute to Microsoft.NET.Sdk.WindowsDesktop and set the UseWindowsForms option to true.

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
    
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.0</TargetFramework>
        <UseWindowsForms>true</UseWindowsForms>
      </PropertyGroup>
    </Project>
    
  4. Paste the code below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    using DevExpress.UnitConversion;
    // ...
    
    QuantityValue<Distance> height = (5.0).Feet() + (4.0).Inches();
    string s = String.Format("The height is {0} ells or {1} meters.",
    height.ToElls().Value.ToString("g3"), height.ToMeters().Value.ToString("g3"));
    Console.WriteLine(s);
    
  5. Run the project.

    result