XmlMappedRange.AutoComplete 方法

从列表中获取一个 AutoComplete 匹配。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)

语法

声明
Function AutoComplete ( _
    String As String _
) As String
string AutoComplete(
    string String
)

参数

返回值

类型:System.String
列表中的 AutoComplete 匹配项。

备注

如果没有 AutoComplete 匹配项,或者列表中有多项与要填写的字符串相匹配,则此方法返回空字符串。

即使 AutoComplete 功能禁用,此方法仍可使用。

示例

下面的代码示例将字符串“Smith”输入单元格 B1,然后使用 AutoComplete 方法查找字符串“Smi”的 AutoComplete 匹配。 此代码示例假定当前工作表包含一个名为 CustomerLastNameCell 的 XmlMappedRange。 如果 CustomerLastNameCell 位于单元格 B2 中,则会找到 AutoComplete 匹配。

Private Sub DisplayAutoCompleteResult()
    Me.Range("B1").Value2 = "Smith"
    Dim autoString As String = Me.CustomerLastNameCell.AutoComplete("Smi")

    If String.IsNullOrEmpty(autoString) Then
        MsgBox("No AutoComplete results were found.")
    Else
        Me.CustomerLastNameCell.Value2 = autoString
    End If
End Sub
private void DisplayAutoCompleteResult()
{
    this.Range["B1", missing].Value2 = "Smith";
    string autoString = this.CustomerLastNameCell.AutoComplete("Smi");

    if (String.IsNullOrEmpty(autoString))
    {
        MessageBox.Show("No AutoComplete results were found.");
    }
    else
    {
        this.CustomerLastNameCell.Value2 = autoString;
    }
}

.NET Framework 安全性

请参见

参考

XmlMappedRange 接口

Microsoft.Office.Tools.Excel 命名空间