DataGridViewColumn.GetPreferredWidth Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Calculates the ideal width of the column based on the specified criteria.
public:
virtual int GetPreferredWidth(System::Windows::Forms::DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight);
public virtual int GetPreferredWidth(System.Windows.Forms.DataGridViewAutoSizeColumnMode autoSizeColumnMode, bool fixedHeight);
abstract member GetPreferredWidth : System.Windows.Forms.DataGridViewAutoSizeColumnMode * bool -> int
override this.GetPreferredWidth : System.Windows.Forms.DataGridViewAutoSizeColumnMode * bool -> int
Public Overridable Function GetPreferredWidth (autoSizeColumnMode As DataGridViewAutoSizeColumnMode, fixedHeight As Boolean) As Integer
- autoSizeColumnMode
- DataGridViewAutoSizeColumnMode
A DataGridViewAutoSizeColumnMode value that specifies an automatic sizing mode.
- fixedHeight
- Boolean
true
to calculate the width of the column based on the current row heights; false
to calculate the width with the expectation that the row heights will be adjusted.
The ideal width, in pixels, of the column.
autoSizeColumnMode
is not a valid DataGridViewAutoSizeColumnMode value.
This property is used by the content-based automatic sizing feature of the DataGridView control to determine the ideal width of a column.
A fixedHeight
parameter value of false
calculates the column width based on calculated row heights that will achieve ideal cell height-to-width ratios. For cell contents to wrap onto multiple lines, the cell style in effect for the cell must have a WrapMode property value of True.
For more information about automatic sizing, see Sizing Options in the Windows Forms DataGridView Control.
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: