執行階段錯誤訊息
錯誤訊息:自動填入的資料行在重新調整大小時,無法執行此作業。
於 System.Windows.Forms.DataGridView.PerformLayoutPrivate(Boolean useRowShortcut, Boolean computeVisibleRows, Boolean invalidInAdjustFillingColumns, Boolean repositionEditingControl)
於 System.Windows.Forms.DataGridView.SetColumnHeadersHeightInternal(Int32 columnHeadersHeight, Boolean invalidInAdjustFillingColumns)
於 System.Windows.Forms.DataGridView.AutoResizeColumnHeadersHeight(Boolean fixedRowHeadersWidth, Boolean fixedColumnsWidth)
於 System.Windows.Forms.DataGridView.OnColumnHeadersGlobalAutoSize()
於 System.Windows.Forms.DataGridView.set_TopLeftHeaderCell(DataGridViewHeaderCell value)
於 System.Windows.Forms.DataGridView.get_TopLeftHeaderCell()
於 System.Windows.Forms.DataGridView.GetCellInternal(Int32 columnIndex, Int32 rowIndex)
於 System.Windows.Forms.DataGridView.OnCellMouseEnter(DataGridViewCellEventArgs e)
於 System.Windows.Forms.DataGridView.UpdateMouseEnteredCell(HitTestInfo hti, MouseEventArgs e)
於 System.Windows.Forms.DataGridView.OnColumnWidthChanged(DataGridViewColumnEventArgs e)
於 System.Windows.Forms.DataGridView.OnBandThicknessChanged(DataGridViewBand dataGridViewBand)
於 System.Windows.Forms.DataGridViewBand.set_ThicknessInternal(Int32 value)
於 System.Windows.Forms.DataGridView.AdjustFillingColumns()
於 System.Windows.Forms.DataGridView.ComputeLayout()
於 System.Windows.Forms.DataGridView.PerformLayoutPrivate(Boolean useRowShortcut, Boolean computeVisibleRows, Boolean invalidInAdjustFillingColumns, Boolean repositionEditingControl)
於 System.Windows.Forms.DataGridView.OnHandleCreated(EventArgs e)
於 System.Windows.Forms.Control.WmCreate(Message& m)
於 System.Windows.Forms.Control.WndProc(Message& m)
於 System.Windows.Forms.DataGridView.WndProc(Message& m)
於 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
於 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
於 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
設計階段發生錯誤
從錯誤訊息推測是 ColumnHeadersHeightSizeMode = AutoSize 造成,從官方文章 DataGridView.ColumnHeadersHeightSizeMode Property 注意到,文件預設值是 EnableResizing,實際在 .NET Framework 上拉一個 DataGridView,預設值為 AutoSize,詢問 AI 是從某一個版本為了 RWD 設計,被修正為 AutoSize,語焉不詳的回答,也沒有辦法確定真偽就是。
在整理 Code 時有順道整合 DataGridView 預設字型,在設計階段時切換 ColumnHeadersHeightSizeMode 屬性 (AutoSize <-> EnableResizing),很明顯觀察到 ColumnHeader 高度一直在變化,把 ColumnHeadersHeightSizeMode 設定為 EnableResizing 並把 ColumnHeader 高度加大 (23 => 28) 可以滿足字型高度來避免該問題


沒有留言:
張貼留言