如何:啟用 Windows Form DataGridView 控制項中的資料行重新調整順序
當您在 DataGridView 控制項中啟用資料行重新調整順序,使用者可以使用滑鼠拖曳資料行標頭,將資料行移至新的位置。 在 DataGridView 控制項中,DataGridView.AllowUserToOrderColumns 屬性值會決定使用者是否能將資料行移至不同位置。
在 Visual Studio 中會支援這項工作。 另請參閱 如何:使用設計工具 在 Windows Forms DataGridView 控制項中啟用資料行重新排序。
以程式設計方式啟用資料行重新調整順序
將 DataGridView.AllowUserToOrderColumns 屬性設為
true
。dataGridView1.AllowUserToOrderColumns = true;
dataGridView1.AllowUserToOrderColumns = True
編譯程式碼
這個範例需要:
名為
dataGridView1
的 DataGridView 控制項。System 和 System.Windows.Forms 組件的參考。
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應