Databases.Item Method

ClosedDescription

Returns a reference to a specified Database object.

This method has the same functionality as the GetDatabase method.

ClosedSyntax

Databases.Item(Index)

Where Index can be either an integer or a string specifying the database name.

ClosedRequirements

Version

BarTender 6.00 or higher

Edition

Automation, Enterprise Automation

ClosedRemarks

Use the Databases.Item method to access a specific database that is setup in a BarTender document. Index can be either an integer value or a string specifying the database name. In VB.NET Databases.Item is the default method for the databases collection, therefore the Databases.Item method does not have to be specified in order to get a reference to a given database object. The database object can be referenced directly using the databases collection. The order of databases in the collection is not guaranteed to be in the order appearing in the database setup of the document. Therefore, we recommend that you reference a database by name, rather than by 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 database variable

Dim btDb As BarTender.Database

'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 database

btDb = btFormat.Databases.Item(1)

'Alternatively, use the database's name if it is known

'btDb = btFormat.Databases.Item("bikes")

'Show the database name

MessageBox.Show(btDb.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 database variable

BarTender.Database btDb;

// 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 database's name,

// Declare a string variable

// string index = "bikes";

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

object obj = index;

// Select the database

btDb = btFormat.Databases.Item(ref obj);

// Show the database's name

MessageBox.Show(btDb.Name);

// End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

Related Topics