Table of contents
TOC
折叠目录
展开目录

DataColumn.SetProperty 方法 (Visio)DataColumn.SetProperty Method (Visio)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

设置指定的数据列属性的值。Sets the value of the specified data-column property.

请注意 此 Visio 对象或成员是仅供授权用户的 Visio 专业 2013年。Note This Visio object or member is available only to licensed users of Visio Professional 2013.

语法Syntax

表达式SetProperty属性expression . SetProperty( Property , Value )

表达式_该表达式返回一个DataColumn对象。_expression An expression that returns a DataColumn object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
属性Property必需RequiredVisDataColumnPropertiesVisDataColumnProperties要设置其值的数据列属性。有关可能值,请参见备注。The data-column property whose value you want set. See Remarks for possible values.
Value必需RequiredVariantVariant要分配给数据列属性的值。有关可能值,请参阅“说明”。The value to assign the data-column property. See Remarks for possible values.

返回值Return Value

Nothing

注解Remarks

在将 Microsoft Visio 绘图中的形状链接到某一数据记录集内的数据时,Visio 会将该数据记录集内的列映射到 ShapeSheet 电子表格的“形状数据”部分中的行,其中每一行均与一个形状数据项相对应。When you link shapes in a Microsoft Visio drawing to data in a data recordset, Visio maps columns in the data recordset to rows in the Shape Data section of the ShapeSheet spreadsheet, each of which corresponds to a shape-data item.

请注意 在某些 Visio 的早期版本中,形状数据被称为自定义属性。Note In some previous versions of Visio, shape data were called custom properties.

数据列属性映射到形状表形状数据部分中的某些单元格的数据列。例如,通过由枚举的值visDataColumnPropertyDisplayName显示名称属性的新值传递SetProperty方法设置标签的单元格的值中的形状数据部分特定的形状数据项的形状表。此外,将该属性设置在形状数据对话框中,以及在 Visio 用户界面中外部数据窗口中显示的数据列的名称设置该形状数据项的标签。这些设置对应于可以在 Visio 用户界面中的列设置对话框中设置 (在外部数据窗口中右键单击,然后单击列设置),以及那些可以使类型中和单位的每个列的对话框中 (单击数据类型列设置对话框中)。Data-column properties map data columns to certain cells in the Shape Data section of the ShapeSheet. For example, by passing the SetProperty method a new value for the DisplayName property, which is represented by the enumerated value visDataColumnPropertyDisplayName , you set the value of the Label cell in the Shape Data section of the ShapeSheet for a particular shape data item. In addition, setting that property sets the label of the shape data item in the Shape Data dialog box, as well as the name of the data column that is displayed in the External Data window in the Visio user interface. These settings correspond to those that you can set in the Column Settings dialog box in the Visio user interface (right-click in the External Data window and then click Column Settings), as well as those that you can make in the Types and Units dialog box for each column (click Data Types in the Column Settings dialog box.)

属性参数的可能值在VisDataColumnProperties ,声明,如下表所示。Possible values for the Property parameter are declared in VisDataColumnProperties , and are shown in the following table.

常量ConstantValue说明Description
* * visDataColumnPropertyCalendar * * visDataColumnPropertyCalendar**33数据列属性的日历。Calendar of the data-column property.
visDataColumnPropertyCurrencyvisDataColumnPropertyCurrency55数据列属性的货币。Currency of the data-column property.
visDataColumnPropertyDisplayNamevisDataColumnPropertyDisplayName66数据列属性在用户界面中的显示名称。Display name of the data-column property in the UI.
visDataColumnPropertyHyperlinkvisDataColumnPropertyHyperlink88数据列值在链接到形状时,是否成为 Visio 用户界面中的超链接。Whether the data-column value becomes a hyperlink in the Visio UI when it is linked to a shape.
visDataColumnPropertyLangIDvisDataColumnPropertyLangID22数据列属性的语言 ID。Language ID of the data-column property.
visDataColumnPropertyTypevisDataColumnPropertyType11数据列属性的数据类型。Data type of the data-column property.
visDataColumnPropertyUnitsvisDataColumnPropertyUnits44数据列属性的单位。Units of the data-column property.
visDataColumnPropertyVisiblevisDataColumnPropertyVisible77数据列属性是否在用户界面中可见。Whether the data-column property is visible in the UI.

属性参数值取决于 Value 参数的可能值。下表显示每个数据列属性,具体取决于数据列数据类型有效的数据列属性值。Possible values for the Value parameter depend on the Property parameter value. The following table shows valid data-column property values for each data-column property, depending on the data-column data type.

********数据列数据类型Data Column Data Type********************
编号 (VisCellVals.visPropTypeNumber)Number (VisCellVals.visPropTypeNumber)日期 (VisCellVals.visPropTypeDate)Date (VisCellVals.visPropTypeDate)货币 (VisCellVals.visPropTypeCurrency)Currency (VisCellVals.visPropTypeCurrency)持续时间 (VisCellVals.visPropTypeDuration)Duration (VisCellVals.visPropTypeDuration)字符串 (VisCellVals.visPropTypeString)String (VisCellVals.visPropTypeString)布尔值 (VisCellVals.visPropTypeBoolean)Boolean (VisCellVals.visPropTypeBoolean)
数据列属性Data Column Property类型TypevisPropTypeNumbervisPropTypeNumbervisPropTypeDatevisPropTypeDatevisPropTypeCurrencyvisPropTypeCurrencyvisPropTypeDurationvisPropTypeDurationvisPropTypeStringvisPropTypeStringvisPropTypeBooleanvisPropTypeBoolean
VisibleVisibleBooleanBooleanBooleanBooleanBooleanBooleanBooleanBooleanBooleanBooleanBooleanBoolean
DisplayNameDisplayNameStringStringStringStringStringStringStringStringStringStringStringString
LangIDLangID有效 LCID 号Valid LCID number
CurrencyCurrency由 3 个字母组成的有效货币常量字符串,用于 Visio ShapeSheet 电子表格中的 CY 函数。Valid 3-letter currency-constant string as used in the CY function in the Visio ShapeSheet spreadsheet.
CalendarCalendar根据 LangID 值VisCellVals的成员之一。(见下表)。One of the members of VisCellVals , depending on the LangID value. (See table below.)
UnitsUnits其中一种VisUnitsCodes的下列成员:One of the following members of VisUnitsCodes :
  • visAcrevisAcre

  • visAngleUnitsvisAngleUnits

  • 字符串visCentimeters

  • visCicerosvisCiceros

  • visCicerosAndDidotsvisCicerosAndDidots

  • visDegreeMinSecvisDegreeMinSec

  • visDegreesvisDegrees

  • visDrawingUnitsvisDrawingUnits

  • visFeetvisFeet

  • visFeetAndInchesvisFeetAndInches

  • visHectarevisHectare

  • visDidotsvisDidots

  • 如厘米、 米visInches

  • visInchFracvisInchFrac

  • visKilometersvisKilometers

  • visMetersvisMeters

  • visMileFracvisMileFrac

  • visMilesvisMiles

  • visMillimetersvisMillimeters

  • visMinvisMin

  • visNautMilesvisNautMiles

  • visPageUnitsvisPageUnits

  • visPicasvisPicas

  • visPicasAndPointsvisPicasAndPoints

  • visPointsvisPoints

  • visRadiansvisRadians

  • visSecvisSec

  • visYardsvisYards

  • visNumber (特殊行为? 此常量使无单位的值)visNumber (special behavior ? this constant makes the value unitless)

用于单位,如_厘米_或_sq cm_的或描述性的 string?a 字符串。将验证该字符串,以便它是受支持的 Visio 单位之一。传递无效字符串会导致此方法失败。
其中一种VisUnitsCodes的下列成员:OR Descriptive string?a string used for units, such as cm or sq cm . This string will be validated so that it is one of the supported Visio units. Passing invalid strings causes the method to fail.One of the following members of VisUnitsCodes :
  • visDurationUnitsvisDurationUnits

  • visElapsedDayvisElapsedDay

  • visElapsedHourvisElapsedHour

  • visElapsedMinvisElapsedMin

  • visElapsedSecvisElapsedSec

  • visElapsedWeekvisElapsedWeek

使用单位如_ew_或描述性 string?a 字符串。将验证该字符串,以便它是受支持的 Visio 单位之一。传递无效字符串会导致此方法失败。
日历CalendarHirjiHirji西欧Western转译法语French Transliterated英语转译English Transliterated希伯来农历Hebrew Lunar萨卡时代Saka Era日本和历Japanese Emperor Era韩国檀纪Korean Danki泰国佛历Thai Buddhist
语言Language
所有阿拉伯语All Arabicxxxxxxxx
孟加拉语(孟加拉国)Bengali(Bangladesh)xxxx
马尔代夫语Divehixxxx
所有英语All Englishxxxxxxxx
波斯语Persianxxxx
希伯来语Hebrewxxxx
印地语Hindixxxx
日语Japanesexxxx
朝鲜语Koreanxxxx
克什米尔语(阿拉伯)Kashmiri (Arabic)xxxx
旁遮普语(巴基斯坦)Punjabi (Pakistan)xxxx
普什图语Pashtoxxxx
信德语Sindhixxxx
泰语Thai
乌尔都语Urduxxxx
柏柏尔语Tamzightxxxx

示例Example

下面的 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用替代方法来获取传递给该方法的数据记录集中的第一列形状数据部分中的标签单元格的值并将其显示在即时窗口。然后它使用SetProperty方法设置的值,并显示新值。更改这个值的更改标签的形状数据项在形状数据对话框中的所有形状链接到数据记录集中的行。The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the GetProperty method to get the value of the Label cell in the Shape Data section for the first column in the data recordset passed to the method and display it in the Immediate window. Then it uses the SetProperty method to set the value and displays the new value. Changing this value changes the label of the shape data item in the Shape Data dialog box for all shapes linked to rows in the data recordset.

获取和设置标签的单元格值,宏传递visDataColumnPropertyDisplayNameVisDataColumnProperties枚举的DataColumn.GetPropertyDataColumn.SetProperty的方法。To get and set the Label cell value, the macro passes the visDataColumnPropertyDisplayName value from the VisDataColumnProperties enumeration to the DataColumn.GetProperty and DataColumn.SetProperty methods.

在运行这个宏之前,至少要在 VBA 项目中创建一个要传递给这个宏的数据记录集。Before running this macro, create at least one data recordset in your VBA project to pass to the macro.


Public Sub SetProperty_Example(vsoDataRecordset As Visio.DataRecordset) 
    Dim strPropertyName As String 
    Dim strNewName As String 
    Dim vsoDataColumn As Visio.DataColumn 

    strNewName = "New Property Name" 
    Set vsoDataColumn = vsoDataRecordset.DataColumns(1) 

    strPropertyName = vsoDataColumn.GetProperty(visDataColumnPropertyDisplayName) 
    Debug.Print strPropertyName 

    vsoDataColumn.SetProperty visDataColumnPropertyDisplayName, strNewName 
    strPropertyName = vsoDataColumn.GetProperty(visDataColumnPropertyDisplayName) 
    Debug.Print strPropertyName 
End Sub
© 2018 Microsoft