SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
Sets all columns' optimal width.
VB.NET | object.MakeOptimal(ByVal MaxScan As Integer) |
VB | object.MakeOptimal(ByVal MaxScan As Long) |
C#.NET | void object.MakeOptimal(int MaxScan); |
VC++ | HRESULT object->MakeOptimal(long MaxScan); |
C | HRESULT object->raw_MakeOptimal(long MaxScan); |
object
MaxScan
The maximum number of items analyzed to determine the optimal column width for all columns. If 0 is specified, all items will be considered.
The MakeOptimal method sets all columns' optimal width.
This method resizes all columns to their optimal width so that the column headers and all cell can be completely displayed without being truncated or clipped.
The Column.MakeOptimal method can be used to resize one single column.
The Column.CalcOptimalWidth method can be used to calculate one column's optimal width without resizing the column. The column width can be changed using the Column.Width property.
By changing control properties, the optimal column width may change. Adding items, setting new cell graphics and changing cell text are a few of the actions that can affect the optimal column width. The column width may have to be set again to allow items to be completely visible. The control does not automatically adjust column widths.
If items are not visible because their parent items are collapsed, these are always excluded from the optimal width calculation.
The combo box control does not automatically adjust column widths.
The last (or only) column may be an "open-ended" column. The Columns.OpenEnded property is set to True. An open-ended column will always use the space remaining between the previous column and the right edge of the control window.
Calculating the optimal column width can be a time consuming operation, particularly if many items have been added to the control. MakeOptimal scans all items to determine the best column width, but can be limited to a specific number of items using the MaxScan argument. This reduces the time spent to calculate the optimal width, but may still leave some items clipped.
Private Sub UpdateFontNames() ' add all font names fontNames.BulkUpdate = True fontNames.Items.Clear() fontNames.Items.AddFontNames(-1, SftBoxFontConstants.fontSftBoxAll, True, 0) fontNames.Items.Selection = 0 PerformSort(fontNames, SftBoxSortConstants.sortSftBoxAscending) fontNames.BulkUpdate = False fontNames.Columns.MakeOptimal(0) fontNames.Items.RecalcHorizontalExtent(0) End Sub Private Sub UpdateFontStyles() ' add all styles for the current font name If fontNames.Items.Selection >= 0 Then Dim OldText As String = fontStyles.Edit.Text
Private Sub UpdateFontNames() ' add all font names FontNames.BulkUpdate = True FontNames.Items.Clear FontNames.Items.AddFontNames -1, fontSftBoxAll, True, 0 FontNames.Items.Selection = 0 PerformSort FontNames FontNames.BulkUpdate = False FontNames.Columns.MakeOptimal 0 FontNames.Items.RecalcHorizontalExtent 0 End Sub Private Sub FontNames_SelectionChange() UpdateStyles End Sub
{ // add all font names fontNames.BulkUpdate = true; fontNames.Items.Clear(); fontNames.Items.AddFontNames(-1, SftBoxFontConstants.fontSftBoxAll, true, 0); fontNames.Items.Selection = 0; PerformSort(fontNames, SftBoxSortConstants.sortSftBoxAscending); fontNames.BulkUpdate = false; fontNames.Columns.MakeOptimal(0); fontNames.Items.RecalcHorizontalExtent(0); } private void UpdateFontStyles() { // add all styles for the current font name if (fontNames.Items.Selection >= 0) {
ISftBoxPtr vFontNames = m_FontNames.GetControlUnknown(); vFontNames->BulkUpdate = VARIANT_TRUE; vFontNames->Items->Clear(); vFontNames->Items->AddFontNames(-1, fontSftBoxAll, VARIANT_TRUE, 0); vFontNames->Items->Selection = 0; PerformSort(vFontNames, sortSftBoxAscending); vFontNames->BulkUpdate = VARIANT_FALSE; vFontNames->Columns->MakeOptimal(0); vFontNames->Items->RecalcHorizontalExtent(0); m_CondHeaders.SetCheck(1); } void CFontDlgDlg::UpdateFontStyles() {
See Also SftBoxColumns Object | Object Hierarchy