Ticket T316636
Visible to All Users

How to apply the saved gauge layout at runtime

created 10 years ago (modified 10 years ago)

Hi!
I use the
AddHandler dash.DashboardItemControlUpdated, AddressOf dash_updated
event, to get the individual componentes of dashboards… for grid, pivot, charts, I to do a lot of changes… colors, series, etc…

So, now for GAUGES, I try change de xml … this way:

Visual Basic
Private Sub dash_updated(sender AsObject, e As DevExpress.DashboardWin.DashboardItemControlEventArgs) If InStr(LCase(e.DashboardItemName), "gaugedashboarditem1") > 0 Then Dim gauge As GaugeControl = e.GaugeControl

And can apply a style, using this

Visual Basic
            If gauge IsNot Nothing Then gauge.RestoreLayoutFromXml(System.Windows.Forms.Application.StartupPath & "\Templates_modelo\circulartemplate2.xml")            end if end sub

FOR ONE GAUGE , Works very fine! change my gauge perfect!!
But usually I have more than one gauge on this control.
How I change in all the gauges?
I tried this way, but not exist "restorelayout" this way:  gauge.Gauges(i)

thanks!!

Comments (2)
DevExpress Support Team 10 years ago

    Aljr,
    I would like to clarify the final goal of this code. How do you wish to modify gauges and why do you need to have their layout? A full understanding of your case will help us to find the best solution for you. I hope to hear from you soon.

      So, because this way I can load all models of gauges from xtragauges!
      (the models of dashboard are limited, few models…) - attach examples… (I save they how xml and load in this event!)

      I kown that works… for ONE gauge works fine! I only need to know how I need to proceed when I have a lot of gauges…
      His colleagues help me this way for grid, pivot and chart, I to do many things!!
      thanks!

      Answers approved by DevExpress Support

      created 10 years ago

      Hi Aljr,

      Please refer to the sample code snippet that illustrates how the selected gauge style can be applied to other gauges. I hope this helps.

      Visual Basic
      Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load     Dim style As StyleCollection = StyleLoader.Load("Circular.Classic.Full")     ChangeGaugeStyle(Me.CircularGauge1, style)     ChangeGaugeStyle(Me.CircularGauge2, style) End Sub Private Sub ChangeGaugeStyle(ByVal gauge As CircularGauge, ByVal styleCollection As StyleCollection)     gauge.BeginUpdate()     gauge.ApplyStyles(styleCollection)     gauge.EndUpdate() End Sub

        Show previous comments (5)
        DevExpress Support Team 9 years ago

          Hi Aljr,

          Thank you for your clarification. I have prepared a sample project to illustrate how to invoke the Style Chooser form manually and obtain the resulting style value. Let me know if you need further assistance.

            Hi Alex, can u do a sample like the "dxSample-VB.zip" in winforms c# and using a dashboard?
            tnks

            DevExpress Support Team 7 years ago

              Hi Adderi,

              The Style Chooser dialog is not a part of the Dashboard UI. The main idea of this example is to extract a particular style name using a standalone application. This way, you can override the Gauge style at runtime by accessing the underlying component. In any case, below is the sample project source code converted to C#. I hope this helps.

              C#
              using DevExpress.XtraGauges.Base; using DevExpress.XtraGauges.Core.Styles; using DevExpress.XtraGauges.Presets.Styles; using DevExpress.XtraGauges.Win.Gauges.Circular; .. private void button1_Click(object sender, EventArgs e) { StyleLoader.RegisterServices(); bool res = ShowStyleChooser(this.circularGauge1); } public bool ShowStyleChooser(IGauge gauge) { StyleCollectionKey result; if (gauge == null || (!ChooseStyleForm.CanEditValue(gauge, out result))) return false; using (ChooseStyleForm styleChooser = new ChooseStyleForm(gauge)) { if (styleChooser.ShowDialog() == System.Windows.Forms.DialogResult.OK) { result = styleChooser.GetResult(); // TODO - save for the future use MessageBox.Show(result.Value); return styleChooser.Apply(result); } return styleChooser.IsStyleChanged; } }

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.