ComponentOne LinearGauge for ASP.NET Web Forms
Task-Based Help / Creatinga Linear Gauge
In This Topic
    Creatinga Linear Gauge
    In This Topic

    Creating a C1LinearGauge control in code is fairly simple. In the following steps you'll add a PlaceHolder control to the page, add an import statement, add and customize the C1LinearGauge, and add the control to the PlaceHolder.


    Complete the following steps:

    1. In Design view, double-click the page to create the Page_Load event and switch to Code view.
    2. Add the following statement to the top of the Code Editor to import the appropriate namespace:

      To write the code in Visual Basic:

      Visual Basic
      Copy Code
      Imports C1.Web.Wijmo.Controls.C1Gauge

      To write the code in C#:

      C#
      Copy Code
      using C1.Web.Wijmo.Controls.C1Gauge;
    3. Add the following code to the Page_Load event to create and customize the C1LinearGauge control.

      To write the code in Visual Basic:

      Visual Basic
      Copy Code
      ' Create a new C1LinearGauge.
      Dim C1LG As New C1LinearGauge
      ' Set the control's size and value.
      C1LG.Height = 100
      C1LG.Width = 500
      C1LG.Min = 0
      C1LG.Max = 100
      C1LG.Value = 60
      ' Add the C1LinearGauge to the PlaceHolder control.
      Dim PlaceHolder1 As New PlaceHolder
      PlaceHolder1.Controls.Add(C1LG)
      form1.Controls.Add(PlaceHolder1)

      To write the code in C#:

      C#
      Copy Code
      // Create a new C1LinearGauge.
      C1LinearGauge C1LG = new C1LinearGauge();
      // Set the control's size and value.
      C1LG.Height = 100;
      C1LG.Width = 500;
      C1LG.Min = 0;
      C1LG.Max = 100;
      C1LG.Value = 60;
      // Add the C1LinearGauge to the PlaceHolder control.
      PlaceHolder PlaceHolder1 = new PlaceHolder();
      PlaceHolder1.Controls.Add(C1LG);
      form1.Controls.Add(PlaceHolder1);

    What You've Accomplished

    Run your application and observe that the C1LinearGauge control was created.

    See Also