DataGridViewColumn.GetPreferredWidth Method
Definition
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
Parameters
- 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.
Returns
The ideal width, in pixels, of the column.
Exceptions
autoSizeColumnMode
is not a valid DataGridViewAutoSizeColumnMode value.
Remarks
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.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기