Add a '+' sign when the number is not negative

Traitée Add a '+' sign when the number is not negative

  • lundi 2 juillet 2012 09:58
     
      A du code

    Hi all, I need your appreciated help.

    I need add a '+' sign when the number is not negative in my chart generate with Chart Controls for .NET Framework

    If try this sql query in MySQL, I have the correct output:

    SELECT CASE WHEN INSTR(Variable, '-') > 0 THEN Variable ELSE CONCAT('+', Variable) END `Output`

           string a = "Output %";
           Chart1.Series.Add(a);
           Chart1.Series[a].LabelFormat = "{0.#}%";
           Chart1.Series[a].YValueMembers = "Output";
           Chart1.Series[a].ChartType = SeriesChartType.Column;
           Chart1.Series[a]["PointWidth"] = "0.85";
           Chart1.Series[a].IsValueShownAsLabel = true;
           Chart1.Series[a]["PixelPointDepth"] = "1.0";
           Chart1.Series[a]["DrawingStyle"] = "Cylinder";
           Chart1.Series[a].Font = new System.Drawing.Font("Verdana", 10, FontStyle.Bold);
           Chart1.Series[a].LabelForeColor = System.Drawing.Color.FromArgb(153, 51, 102);//255, 0, 0);
           Chart1.Series[a]["LabelStyle"] = "Bottom";
           Chart1.Series[a].Color = System.Drawing.Color.FromArgb(153, 51, 102);

    When I try the same query in C# language Chart Controls for .NET Framework I don't have the  '+' sign when the number is not negative in my chart.

    If you have link for similar task, please give it me.
    Can you explain any one or any sample code related this.

    Your help would be very appreciated.
    thanks for your time and hints.

    Thanks in advance,
    Chevy
    • Modifié cms9651 lundi 2 juillet 2012 09:59
    •  

Toutes les réponses

  • lundi 2 juillet 2012 10:49
     
     Traitée A du code

    Not sure, but try this:

    Chart1.Series[a].LabelFormat = "{0:+.#;-.#}%";

    • Marqué comme réponse cms9651 lundi 2 juillet 2012 11:34
    •  
  • lundi 2 juillet 2012 11:34
     
     

    Yes!

    Your suggestion working!

    Thanks a lot !