property Column.Def(Property as DefColumnEnum) as Variant
Retrieves or sets a value that indicates the default value of given properties for all cells in the same column.

 TypeDescription 
   Property as DefColumnEnum A DefColumnEnum expression that indicates the property being changed.  
   Variant A Variant value that specifies the newly value.  
Use the Def property to specify a common value for given properties for all cells in the column. For instance, you can use the Def property to assign check boxes to all cells in the column, without enumerating them. Use the ConditionalFormats method to apply formats to a cell or range of cells, and have that formatting change depending on the value of the cell or the value of a formula.

The following VB sample assigns checkboxes for all cells in the first column: 

List1.Columns(0).Def(exCellHasCheckBox) = True

The following VB sample changes the background color for all cells in the first column:

List1.Columns(0).Def(exCellBackColor) = RGB(240, 240, 240)

The following C++ sample assigns checkboxes for all cells in the first column: 

COleVariant vtCheckBox( VARIANT_TRUE );
m_list.GetColumns().GetItem( COleVariant( (long) 0 ) ).SetDef( /*exCellHasCheckBox*/ 0, vtCheckBox );

The following C++ sample changes the background color for all cells in the first column:

COleVariant vtBackColor( (long)RGB(240, 240, 240) );
m_list.GetColumns().GetItem( COleVariant( (long) 0 ) ).SetDef( /*exCellBackColor*/ 4, vtBackColor );

The following VB.NET sample assigns checkboxes for all cells in the first column: 

With AxList1.Columns(0)
    .Def(EXLISTLib.DefColumnEnum.exCellHasCheckBox) = True
End With

The following VB.NET sample changes the background color for all cells in the first column:

With AxList1.Columns(0)
    .Def(EXLISTLib.DefColumnEnum.exCellBackColor) = ToUInt32(Color.WhiteSmoke)
End With

where the ToUInt32 function converts a Color expression to OLE_COLOR,

Shared Function ToUInt32(ByVal c As Color) As UInt32
    Dim i As Long
    i = c.R
    i = i + 256 * c.G
    i = i + 256 * 256 * c.B
    ToUInt32 = Convert.ToUInt32(i)
End Function 

The following C# sample assigns checkboxes for all cells in the first column: 

axList1.Columns[0].set_Def( EXLISTLib.DefColumnEnum.exCellHasCheckBox, true );

The following C# sample changes the background color for all cells in the first column:

axList1.Columns[0].set_Def(EXLISTLib.DefColumnEnum.exCellBackColor, ToUInt32(Color.WhiteSmoke));

where the ToUInt32 function converts a Color expression to OLE_COLOR,

private UInt32 ToUInt32(Color c)
{
	long i;
	i = c.R;
	i = i + 256 * c.G;
	i = i + 256 * 256 * c.B;
	return Convert.ToUInt32(i);
}

The following VFP sample assigns checkboxes for all cells in the first column:

with thisform.List1.Columns(0)
	.Def( 0 ) = .t.
endwith

The following VFP sample changes the background color for all cells in the first column:

with thisform.List1.Columns(0)
	.Def( 4 ) = RGB(240,240,240)
endwith
 

Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.