How to format the CalcQuick result in WinForms Calculate?
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 Calculate, the 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,
- int.Parse
- double.Parse
- 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
The SetDirty() method is used for every calculations. I.e. whenever you are calculating the formulas with different values.
Refer to the following screenshot.
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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!