Platforms to show: All Mac Windows Linux Cross-Platform

NSCollectionViewGridLayoutMBS class

Superclass: NSCollectionViewLayoutMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Cocoa Collection View MBS MacControls Plugin 21.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
A layout that displays a single section of items in a row and column grid..
Example
// This example needs a window with NSCollectionViewControlMBS1.
// show the items of a collection view in a grid with at most 4 columns
Var layout As New NSCollectionViewGridLayoutMBS
layout.maximumNumberOfColumns = 4
layout.minimumItemSize = NSMakeSizeMBS(80, 80)
layout.maximumItemSize = NSMakeSizeMBS(160, 160)
layout.minimumInteritemSpacing = 8
layout.minimumLineSpacing = 8
layout.margins = New NSEdgeInsetsMBS(10, 10, 10, 10)

NSCollectionViewControlMBS1.View.collectionViewLayout = layout

The NSCollectionViewGridLayoutMBS object provides the same layout behavior offered by the NSCollectionViewMBS class prior to macOS 10.11, and you can use it in cases where you want to maintain the old appearance while still taking advantage of newer collection view features.

Configuring a Collection View to Use a Grid Layout

You can configure a collection view to use a grid layout object programmatically or at design time

  • At design time, set the Layout attribute of your collection view to Grid.
Create an NSCollectionViewGridLayoutMBS object programmatically and assign it to the collection view’s collectionViewLayout property
  • A grid layout displays only items and does not display supplementary views or decoration views. Use the properties of this class to configure the number of rows and columns in the grid. You can also use these properties to configure the spacing between items and the minimum sizes.
Subclass of the NSCollectionViewLayoutMBS class.

Highlight States

Constant Value Description
HighlightAsDropTarget 3 The drop target highlight state. This type of highlight is applied when the item is the target of a drop operation on the collection view. After the drop operation completes, the highlight state returns to HighlightNone.
HighlightForDeselection 2 The deselection highlight state. During interactive selection, this state is used to indicate that the item will become deselected when interactions end. After interactions end, the highlight state returns to HighlightNone.
HighlightForSelection 1 The selected highlight state. This type of highlight is applied when an item is selected. During interactive highlighting, this state is also applied to indicate that the item will become highlighted.
HighlightNone 0 No highlight state.

Superclass NSCollectionViewLayoutMBS

This class has no subclasses.

Some related classes:


The items on this page are in the following plugins: MBS MacControls Plugin.


NSCollectionViewFlowLayoutMBS   -   NSCollectionViewItemMBS


The biggest plugin in space...