DataGridViewCell.PreferredSize 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得能夠容納儲存格的矩形區域大小 (以像素為單位)。
public:
property System::Drawing::Size PreferredSize { System::Drawing::Size get(); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Size PreferredSize { get; }
[<System.ComponentModel.Browsable(false)>]
member this.PreferredSize : System.Drawing.Size
Public ReadOnly Property PreferredSize As Size
屬性值
Size,包含高度和寬度 (單位為像素)。
- 屬性
例外狀況
ColumnIndex 小於 0,表示儲存格是資料列行首儲存格。
備註
屬性 PreferredSize 會傳回儲存格擁有之資料列和資料行所計算之儲存格的自然大小。 PreferredSize Size如果儲存格未包含在表格中,則會傳回寬度和高度為 -1 的 。
如果儲存格位於 的 中 DataGridViewColumn ,且其 Resizable 屬性設定為 false
,則會針對寬度傳回 -1。
這個方法依賴 GetFormattedValue 方法。