我有 2 DataGridViews。假設它們總是具有相同高度的相同數量的行。每當我ScrollBar在其中一個上移動 時(同時使用MouseWheel和ScrollBar),我想同時移動另一個(我只想在垂直上執行此操作ScrollBars)。我怎樣才能做到這一點?
uj5u.com熱心網友回復:
@Caius Jard 對你說的是:
首先,創建兩個 DataGridView,然后在Scroll事件上同步FirstDisplayedScrollingRowIndex.
dataGridView1.Scroll = DataGridView1OnScroll;
private void DataGridView1OnScroll(object sender, ScrollEventArgs scrollEventArgs) {
dataGridView2.FirstDisplayedScrollingRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex;
}
觀察
我嘗試使用 thisWndProc來同步兩個 DataGrids,但它不起作用……嗯,它可以與滑鼠滾輪一起使用,但不能通過拖動滾動條來使用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/318269.html
上一篇:如何允許用戶更改下載路徑?
