DataGridBoolColumn.AllowNull 属性

获取或设置一个值,该值指示是否允许空值。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Property AllowNull As Boolean
用法
Dim instance As DataGridBoolColumn
Dim value As Boolean

value = instance.AllowNull

instance.AllowNull = value
public bool AllowNull { get; set; }
public:
property bool AllowNull {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AllowNull ()

/** @property */
public void set_AllowNull (boolean value)
public function get AllowNull () : boolean

public function set AllowNull (value : boolean)

属性值

如果允许空值,则为 true ;否则为 false。默认为 true

备注

当此属性设置为 false 时,此列中的复选框仅有两个状态:已选中 (true) 和未选中 (false)。

示例

下面的代码示例设置 AllowNull 属性。

Private Sub SetAllowNull()
    Dim myGridColumn As DataGridBoolColumn = CType(dataGrid1.TableStyles(0).GridColumnStyles(0), DataGridBoolColumn)
    myGridColumn.AllowNull = False
End Sub 'SetAllowNull
private void SetAllowNull(){
    DataGridBoolColumn myGridColumn = (DataGridBoolColumn)dataGrid1.TableStyles[0].GridColumnStyles[0];
    myGridColumn.AllowNull = false;
 }
 
void SetAllowNull()
{
   DataGridBoolColumn^ myGridColumn = dynamic_cast<DataGridBoolColumn^>(dataGrid1->TableStyles[ 0 ]->GridColumnStyles[ 0 ]);
   myGridColumn->AllowNull = false;
}
private void SetAllowNull()
{
    DataGridBoolColumn myGridColumn = 
        (DataGridBoolColumn)(dataGrid1.get_TableStyles().
        get_Item(0).get_GridColumnStyles().get_Item(0));
    myGridColumn.set_AllowNull(false);
} //SetAllowNull

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

DataGridBoolColumn 类
DataGridBoolColumn 成员
System.Windows.Forms 命名空间
AllowDBNull
NullValue
Value