Back to Devexpress

DefinedNameCollection.GetDefinedName(String) Method

officefileapi-devexpress-dot-spreadsheet-dot-definednamecollection-dot-getdefinedname-x28-system-dot-string-x29.md

latest4.1 KB
Original Source

DefinedNameCollection.GetDefinedName(String) Method

Returns the DefinedName object with the specified DefinedName.Name property value.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
DefinedName GetDefinedName(
    string name
)
vb
Function GetDefinedName(
    name As String
) As DefinedName

Parameters

NameTypeDescription
nameString

A String value that is the name of the defined name to be found. This name is specified by the DefinedName.Name property.

|

Returns

TypeDescription
DefinedName

A DefinedName object that has the specified name. Null ( Nothing in VB), if no object with the specified name is found.

|

Remarks

Use the GetDefinedName property to get the DefinedName object by its name - a string value (DefinedName.Name) by which the associated cell, range of cells, formula or constant (DefinedName.RefersTo) can be accessed. For detailed information on defined names, refer to the Defined Names document.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetDefinedName(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-spreadsheet-use-custom-cell-editors/CS/DevAVInvoicing/Form1.cs#L117

csharp
if (sheet.Name == "Invoice") {
    DefinedName invoiceItems = sheet.DefinedNames.GetDefinedName("InvoiceItems");
    btnRemoveRecord.Enabled = invoiceItems != null && invoiceItems.Range.RowCount > 1 && invoiceItems.Range.IsIntersecting(sheet.SelectedCell);

winforms-spreadsheet-use-custom-cell-editors/VB/DevAVInvoicing/Form1.vb#L108

vb
If Equals(sheet.Name, "Invoice") Then
    Dim invoiceItems As DefinedName = sheet.DefinedNames.GetDefinedName("InvoiceItems")
    btnRemoveRecord.Enabled = invoiceItems IsNot Nothing AndAlso invoiceItems.Range.RowCount > 1 AndAlso invoiceItems.Range.IsIntersecting(sheet.SelectedCell)

See Also

Defined Names

DefinedNameCollection Interface

DefinedNameCollection Members

DevExpress.Spreadsheet Namespace