You can host a C1Gauge control in a C1RibbonGroup or in a C1StatusBar control through using the RibbonControlHost element. Complete the following steps to embed a C1Gauge in a C1RibbonGroup:
Note: This help uses a template file to create the ruler view for the C1Gauge control. To create this file, add a C1Gauge control to a Windows Form and choose the Linear Gauge Simple Ruler template from the New Gauge Gallery dialog box. Open the C1Gauge smart tag and click Save to XML File. Enter the file name Ruler.xml and click Save.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Partial Class Form1 Inherits C1.Win.C1Ribbon.C1RibbonForm End Class |
To write code in C#
C# |
Copy Code
|
---|---|
public partial class Form1 : C1RibbonForm |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Imports C1.Win.C1Gauge Imports System.Xml |
To write code in C#
C# |
Copy Code
|
---|---|
using C1.Win.C1Gauge; using System.Xml; |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Public Class GaugeHostControl Inherits C1.Win.C1Ribbon.RibbonControlHost Private linearGauge As C1LinearGauge Public Sub New() MyBase.New(New C1.Win.C1Gauge.C1Gauge) linearGauge = New C1LinearGauge Dim doc As XmlDocument = New XmlDocument doc.LoadXml(Properties.Resources.Ruler) linearGauge.Load(doc) C1Gauge.Gauges.Add(linearGauge) C1Gauge.BackColor = System.Drawing.Color.Azure linearGauge.PointerDragMove = (linearGauge.PointerDragMove + LinearGauge_PointerDragMove) End Sub <Browsable(false), _ DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _ Public ReadOnly Property C1Gauge As C1.Win.C1Gauge.C1Gauge Get Return CType(Control,C1.Win.C1Gauge.C1Gauge) End Get End Property Private Sub LinearGauge_PointerDragMove(ByVal sender As Object, ByVal e As PointerDragEventArgs) e.Pointer.UpdateValue(e.NewValue, 0.5) End Sub End Class |
To write code in C#
C# |
Copy Code
|
---|---|
public class GaugeHostControl : C1.Win.C1Ribbon.RibbonControlHost { private C1LinearGauge linearGauge; public GaugeHostControl() : base(new C1.Win.C1Gauge.C1Gauge()) { linearGauge = new C1LinearGauge(); XmlDocument doc = new XmlDocument(); doc.LoadXml(Properties.Resources.Ruler); linearGauge.Load(doc); C1Gauge.Gauges.Add(linearGauge); C1Gauge.BackColor = System.Drawing.Color.Azure; linearGauge.PointerDragMove += LinearGauge_PointerDragMove; } [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public C1.Win.C1Gauge.C1Gauge C1Gauge { get { return (C1.Win.C1Gauge.C1Gauge)Control; } } private void LinearGauge_PointerDragMove(System.Object sender, PointerDragEventArgs e) { e.Pointer.UpdateValue(e.NewValue, 0.5); } } |