<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSBrowser/setWidth(_:ofColumn:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBrowser(im)setWidth:ofColumn:"
  },
  "title" : "setWidth(_:ofColumn:)"
}
-->

# setWidth(_:ofColumn:)

Sets the width of the specified column.

```
func setWidth(_ columnWidth: CGFloat, ofColumn columnIndex: Int)
```

## Parameters

`columnWidth`

The new width of the specified column.

`columnIndex`

The index of the column for which to set the width.

## Discussion

This method can be used to set the initial width of browser columns unless the column sizing is automatic; [`setWidth(_:ofColumn:)`](/documentation/AppKit/NSBrowser/setWidth(_:ofColumn:)) does nothing if [`columnResizingType`](/documentation/AppKit/NSBrowser/columnResizingType-swift.property) is [`NSBrowser.ColumnResizingType.autoColumnResizing`](/documentation/AppKit/NSBrowser/ColumnResizingType-swift.enum/autoColumnResizing). To set the default width for new columns (that don’t otherwise have initial widths from defaults or via the delegate), use a `columnIndex` of –1. A value set for `columnIndex` of –1 is persistent. An [`columnConfigurationDidChangeNotification`](/documentation/AppKit/NSBrowser/columnConfigurationDidChangeNotification) notification is posted (not immediately), if necessary, so that the browser can autosave the new column configuration.

## See Also

[`func browser(NSBrowser, shouldSizeColumn: Int, forUserResize: Bool, toWidth: CGFloat) -> CGFloat`](/documentation/AppKit/NSBrowserDelegate/browser(_:shouldSizeColumn:forUserResize:toWidth:))

Used to determine a column’s initial size.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)