Version

TreatAsType Property

Gets or sets a Type to use for conversion purposes when the UltraCalcManager interprets the value from the Control.
Syntax
'Declaration
 
Public Property TreatAsType As Type
public Type TreatAsType {get; set;}
Remarks

TreatAsType is useful if you are using values in a Calculation that are not neccessarily in the native type for the formula. For example, if a TextBox control's Text property is being used to enter a numeric value, the CalcManager will, by default, convert that contents of the TextBox to a Double using the Invariant Culture. This may not always be the desired effect. Setting TreatAsType to double in this example would convert the Text of the TextBox to a Double using the Current (instead of Invariant) Culture before passing the value on to the CalcManager.

Setting TreatAsType also allows the CalcManager to validate the data and display an error if it cannot be converted to the appropriate type. This means that if TreatAsType has been set and the property value of the control cannot be converted to the proper type, an ErrorIcon will be displayed. Without setting TreatAsType, only controls which are using the control as a source will be able to display an error.

Example
Following code assigns a formula to textBox1 that multiplies the value of textBox2 by 2.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports Infragistics.Win.CalcEngine
Imports Infragistics.Win.UltraWinCalcManager

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Ensure that the form contains an UltraCalcManager and two textboxes, 
        ' one named textBox1 and the other named textBox2.
        Dim calcSettings As CalcSettings = New CalcSettings()
        ' This formula will multiply the value of textBox2 by 2.
        calcSettings.Formula = "2 * [//textBox2]"
        calcSettings.PropertyName = "Text"
        Me.ultraCalcManager1.SetCalcSettings(Me.TextBox1, calcSettings)

        calcSettings = New CalcSettings()
        calcSettings.PropertyName = "Text"
        ' Treat the values of the textBox2 as double. Text property of TextBox is
        ' a string type and since textBox2 is a source of value to a formula, indicate 
        ' to the calc-manager that the value should be treated as a double rather
        ' than as a string. 
        calcSettings.TreatAsType = GetType(Double)
        Me.ultraCalcManager1.SetCalcSettings(Me.TextBox2, calcSettings)
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;
using Infragistics.Win.CalcEngine;
using Infragistics.Win.UltraWinCalcManager;

		private void Form1_Load(object sender, System.EventArgs e)
		{
			// Ensure that the form contains an UltraCalcManager and two textboxes, 
			// one named textBox1 and the other named textBox2.
			CalcSettings calcSettings = new CalcSettings( );
			// This formula will multiply the value of textBox2 by 2.
			calcSettings.Formula = "2 * [//textBox2]";
			calcSettings.PropertyName = "Text";
			this.ultraCalcManager1.SetCalcSettings( this.textBox1, calcSettings );

			calcSettings = new CalcSettings( );
			calcSettings.PropertyName = "Text";
			// Treat the values of the textBox2 as double. Text property of TextBox is
			// a string type and since textBox2 is a source of value to a formula, indicate 
			// to the calc-manager that the value should be treated as a double rather
			// than as a string. 
			calcSettings.TreatAsType = typeof( double );
			this.ultraCalcManager1.SetCalcSettings( this.textBox2, calcSettings );
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also