Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

SftBoxCell.Data Property

Defines the cell's application specific numeric value.

Syntax

Get

VB.NETNumber = object.Data As Integer
VBNumber = object.Data As Long
C#.NETint Number = object.Data;
VC++LONG_PTR Number = object->Data;
LONG_PTR Number = object->GetData();
CHRESULT object->get_Data(LONG_PTR* Number);

Put

VB.NETobject.Data = Number As Integer
VBobject.Data = Number As Long
C#.NETint object.Data = Number;
VC++LONG_PTR object->Data = Number;
void object->PutData(LONG_PTR Number);
CHRESULT object->put_Data(LONG_PTR Number);

object

A SftBoxCell object.

Number

Defines the cell's application specific numeric value. This data is application defined, but is also used by the Items.AddFontNames, AddFontStyles, AddFontSizes methods.

Comments

The Data property defines the cell's application specific numeric value.

The Items.AddFontNames, Items.AddFontStyles, Items.AddFontSizes methods store additional information in the Data property for each item added.

The Data property can be used for sorting purposes using the Items.Sort method or can be located using the Items.FindCellData method.

The Cell.DataString, Cell.DataObject, Cell.DataTag properties can be used to store additional application specific data, using other data types (strings, objects, variants).

Additional properties used to associate an application defined value with an item are Item.Data, Item.DataTag and Item.DataObject. These are distinct properties and can be used at the same time.

Examples

VB.NET

End Sub

Private Sub UpdateSample()
    Dim SelItem As Integer = fontStyles.Items.Selection
    If SelItem >= 0 And fontSizes.Edit.Text <> "" Then
        sampleText.Text = "AaBbCcYyZz"
        Dim style As FontStyle = 0
        If (fontStyles.get_Cell(SelItem, 0).Data And &H80000000&) <> 0 Then style = style Or FontStyle.Italic
        Dim weight As Integer = fontStyles.get_Cell(SelItem, 0).Data And &H7FFFFFFF&
        If weight > 400 Then style = style Or FontStyle.Bold
        sampleText.Font = New Font(fontNames.Edit.Text, Convert.ToSingle(fontSizes.Edit.Text), style)
    Else
        sampleText.Text = ""
    End If
End Sub

VB6

    If SftBoxCtrl.Header(0).Image.Appearance = sftImageSortAsc Then
        SftBoxCtrl.Header(0).Image.Appearance = sftImageSortDesc
    Else
        SftBoxCtrl.Header(0).Image.Appearance = sftImageSortAsc
    End If
End Sub

Private Sub PerformCellValueSort(SftBoxCtrl As SftBox)
    ' Font sizes are sorted according to numeric Cell.Data property
    If SftBoxCtrl.Header(0).Image.Appearance = sftImageSortAsc Then
        SftBoxCtrl.Items.Sort -1, 0, sortSftBoxCellValueAscending
    Else
        SftBoxCtrl.Items.Sort -1, 0, sortSftBoxCellValueDescending
    End If
End Sub

C#

}

private void UpdateSample()
{
    int SelItem = fontStyles.Items.Selection;
    if (SelItem >= 0 && fontSizes.Edit.Text != "") {
        sampleText.Text = "AaBbCcYyZz";
        FontStyle style = 0;
        if ((fontStyles.get_Cell(SelItem, 0).Data & 0x80000000) != 0)
            style |= FontStyle.Italic;
        int weight = (fontStyles.get_Cell(SelItem, 0).Data & 0x7fffffff);
        if (weight > 400)
            style |= FontStyle.Bold;
        sampleText.Font = new Font(fontNames.Edit.Text, Convert.ToSingle(fontSizes.Edit.Text), style);
    } else
        sampleText.Text = "";

C++

{
    ISftBoxPtr vFontNames = m_FontNames.GetControlUnknown();
    ISftBoxPtr vFontStyles = m_FontStyles.GetControlUnknown();
    ISftBoxPtr vFontSizes = m_FontSizes.GetControlUnknown();

    long SelItem = vFontStyles->Items->Selection;
    if (SelItem >= 0 && lstrcmp(vFontSizes->Edit->Text, "") != 0) {
        m_Sample.SetWindowText(_T("AaBbCcYyZz"));
        long val = (long) vFontStyles->Cell[SelItem][0]->Data;
        BOOL fItalic = (val & 0x80000000L) != 0;
        val &= 0x7fffffff;

        m_SampleFont.DeleteObject();
        // convert point size to pixels
        CDC* pDC;
        pDC = GetDC();

See Also SftBoxCell Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.