API Documentation -> NtApplication -> NtGetText

# NtApplication.NtGetText Method

Whenever a data object shall be displayed as text, the NtTimeChartControl needs to know the string to draw. So it will call this interface method to call your code. You will retreive the NtDataObject as a parameter. Your data is contained in the NtDataObject.dataItem member, so you can compose the text properly. In most cases you simply return ntDo.dataItem.ToString().

Overload List:

Modifier / Return Value | Name and Parameters | Description
--- | --- | ---
string | NtGetText ( NtDataObject ntDo ) | For the data object given as parameter you will return the correct string representation.

Return value:

string
The string that represents the object.

Parameters:

NtDataObject ntDo
The data object that the Time Chart needs a string for.

Remarks:

The Time Chart guarantees to only call this interface mamber for those objects that are defined to be represented as text. For others that are to be drawn as bitmaps, icons or curves this method will never be called. This is important because you do not need to check the data type for these types. In other words, if all data objects that shall be drawn as text are of the same type (e.g. string) you can omit the casting completely. Please see the example below.

Example:

In many cases this function is sufficiently implemented by simply returning the object's string:

public string NtGetText(NtDataObject ntDo)
{
return ntDo.dataItem.ToString();
}

Now assume you added various data types to your Time Chart that all shall be drawn as text. The data types differ by their dataTypeId that you can use to differentiate. For example we have temperature values with dataTypeId 100 and Customers with dataTypeId 110:

public string NtGetText(NtDataObject ntDo)
{
if (ntDo.dataTypeId == 100) return "" + (double)ntDo.dataItem;
if (ntDo.dataTypeId == 110) return ((Customer)ntDo.dataItem).firstName + " " + ((Customer)ntDo.dataItem).lastName;
return ntDo.dataItem.ToString();
}

See also:

NtGetBitmap()
NtGetIcon()
NtGetDouble()

Top API Documentation -> NtApplication -> NtGetText © 2016 Bassaly