NamedSubStrings.Item Method

ClosedDescription

Returns a reference to a specified SubString object.

This method has the same functionality as the GetSubString method.

ClosedSyntax

NamedSubStrings.Item(Index)

Where Index can be either an integer or a string specifying the name of the data source.

ClosedRequirements

Version

BarTender 6.00 or higher

Edition

Automation, Enterprise

ClosedRemarks

Use the NamedSubStrings.Item method to access a specific SubString object that is setup on a template. Index can be either an integer value or a string index specifying the name of the data source. In VB.NET, NamedSubStrings.Item is the default method for the NamedSubStrings collection, therefore the Item method does not have to be specified in order to get a reference to a given SubString object. The SubString object can be referenced directly using the NamedSubStrings collection. The order of SubString objects in the collection is not guaranteed to be in the order of data sources in the object(s). Therefore it is preferred to reference a SubString object by its name, rather by an integer index.

ClosedVB.NET Example

'Declare a BarTender application variable

Dim btApp As BarTender.Application

'Declare a BarTender document variable

Dim btFormat As BarTender.Format

'Declare a BarTender data source variable

Dim btSubString As BarTender.SubString

'Create a new instance of BarTender

btApp = New BarTender.Application

'Set the BarTender application visible

btApp.Visible = True

'Open a BarTender document

btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")

'Select the data source

btSubString = btFormat.NamedSubStrings.Item(1)

'Alternatively, use the data source's name if it is known

'btSubString = btFormat.NamedSubStrings.Item("bikes")

'Display the data source's name

MessageBox.Show(btSubString.Name)

'End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)

ClosedC# Example

// Declare a BarTender application variable

BarTender.Application btApp;

// Declare a BarTender document variable

BarTender.Format btFormat;

// Declare a BarTender data source variable

BarTender.SubString btSubString;

// Declare an object variable

System.Object obj;

// Create a new instance of BarTender

btApp = new BarTender.Application();

// Set the BarTender application visible

btApp.Visible = true;

// Open a BarTender document

btFormat = btApp.Formats.Open("c:\\Format1.btw", false, "");

// Declare an index variable and set to the index value

int index = 1;

// Alternatively, if you plan to use the data source's name,

// Declare a string variable

// string index = "bikes";

// Set the object variable to the value of the index variable

obj = index;

// Select the data source

btSubString = btFormat.NamedSubStrings.Item(ref obj);

// Display the data source's name

MessageBox.Show(btSubString.Name);

// End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

Related Topics