Articles in this section
Category / Section

How to format the CalcQuick result in WinForms Calculate?

1 min read

Description

By default, the values from the particular key in CalcQuick are returned as an object value. This value can be converted as a string by using ToString() method. As separate support is not provided to format the result of the WinForms Calculatethe result is formatted as the following suggested way.

Solution

To format the result of the CalcQuick calculations, the result can be parsed by using any of the formatting methods. For example,

  1. int.Parse
  2. double.Parse
  3. decimal.Parse

C#

private void calculateBtn_Click(object sender, EventArgs e)
{
        //Reassigns the key values to the CalcQuick
        calculator["A"] = this.value1Text.Text;
        calculator["B"] = this.value2Text.Text;
        calculator["C"] = this.formulaText.Text;
         //Used to recalculate the all formulas in CalcQuick
         calculator.SetDirty();
          //Formats the result string after parsed as double
          this.resultText.Text = double.Parse(calculator["C"].ToString()).ToString("#,##0.00");
}

 

VB

Private Sub calculateBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles calculateBtn.Click
    'Reassigns the formula if changed
     calculator("A") = Me.value1Text.Text
     calculator("B") = Me.value2Text.Text
     calculator("C") = Me.formulaText.Text    
    'Used to recalculate the all formulas in CalcQuick
     calculator.SetDirty()
     'Formats the result string after parsed as double
      Me.resultText.Text = Double.Parse(calculator("C").ToString()).ToString("#,##0.00")
End Sub

 

Note:

The SetDirty() method is used for every calculations. I.e. whenever you are calculating the formulas with different values.

 

Refer to the following screenshot.

Showing formatted result in WinForms Calculation Engine

Sample Links:

C#: Formatting_Results_CalcQuick_CS

VB: Formatting_Results_CalcQuick_VB


Conclusion

I hope you enjoyed learning about how to format the CalcQuick result in WinForms Calculate.

You can refer to our WinForms Calculate feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied