HeaderPane
Main
Hide
Share Link
Print

AddFontSizes Method, SftBoxItems Object

Adds a list of available font sizes.

Syntax

C#int Count = object.AddFontSizes(string FontName, int hDCPrinter);
VB.NETCount = object.AddFontSizes(ByVal FontName As String, ByVal hDCPrinter As Integer) As Integer
C++long Count = object->AddFontSizes(_bstr_t FontName, long hDCPrinter);
CHRESULT object->raw_AddFontSizes(BSTR FontName, long hDCPrinter, long* Count);

object

A SftBoxItems object.

FontName

The name of the font whose font sizes are to be added to the control.

hDCPrinter

Specify a valid printer device context handle if the font FontName is a printer font. Specify 0 for screen fonts.

Count

Returns the number of font sizes added to the control.

Comments

The AddFontSizes method adds a list of available font sizes.

The AddFontSizes method adds all available font sizes (in points) of the font FontName to the combo box as items. The combo box is cleared first.

Font sizes are added in ascending order.

The Cell.Data property of the cell in column 0 of each item will contain the font size, which could be used for sorting purposes.

The drop down portion is automatically hidden when the combo box contents are changed using this method. The DropDown.SuppressOn method can be used to suppress hiding the drop down portion when adding/inserting items.

Examples

C# View entire sample code

            fontStyles.Items.RecalcHorizontalExtent(0);
        }

        private void UpdateFontSizes()
        {
            // add all sizes for the current font name
            if (fontNames.Items.Selection >= 0) {
                string OldText = fontSizes.Edit.Text;
                fontSizes.Items.AddFontSizes(fontNames.get_Cell(fontNames.Items.Selection,0).Text, 0);
                int index = fontSizes.Items.Find(OldText, 0, 0, false, true, true);
                if (index < 0) index = 0;
                fontSizes.Items.Selection = index;
            } else
                fontSizes.Items.Clear();
            PerformSort(fontSizes, SftBoxSortConstants.sortSftBoxAscending); 
            fontSizes.Columns.MakeOptimal(0);

VB.NET View entire sample code

    fontStyles.Columns.MakeOptimal(0)
    fontStyles.Items.RecalcHorizontalExtent(0)
End Sub

Private Sub UpdateFontSizes()
    ' add all sizes for the current font name
    If fontNames.Items.Selection >= 0 Then
        Dim OldText As String = fontSizes.Edit.Text
        fontSizes.Items.AddFontSizes(fontNames.get_Cell(fontNames.Items.Selection, 0).Text, 0)
        Dim index As Integer = fontSizes.Items.Find(OldText, 0, 0, False, True, True)
        If index < 0 Then index = 0
        fontSizes.Items.Selection = index
    Else
        fontSizes.Items.Clear()
    End If
    PerformSort(fontSizes, SftBoxSortConstants.sortSftBoxAscending)

C++ View entire sample code

void CFontDlgDlg::UpdateFontSizes()
{
    // add all sizes for the current font name
    ISftBoxPtr vFontNames = m_FontNames.GetControlUnknown();
    ISftBoxPtr vFontSizes = m_FontSizes.GetControlUnknown();

    if (vFontNames->Items->Selection >= 0) {
        CString OldText((LPCTSTR) vFontSizes->Edit->Text);
        vFontSizes->Items->AddFontSizes(vFontNames->Cell[vFontNames->Items->Selection][0]->Text, 0);
        long index;
        vFontSizes->Items->raw_Find((_bstr_t)OldText, 0, 0, VARIANT_FALSE, VARIANT_TRUE, VARIANT_TRUE, &index);
        if (index < 0) index = 0;
        vFontSizes->Items->Selection = index;
    } else
        vFontSizes->Items->Clear();
    PerformSortSize(vFontSizes, sortSftBoxAscending);

See Also SftBoxItems Object | Object Hierarchy


Last Updated 11/22/2026 - (email)
© 2026 Softel vdm, Inc.