2013-10-17 31 views
1

我需要在更新\ work時在我的DataGridView上平滑優雅的滾動。面板中的DataGridView無法滾動

因爲每次我更新我的DataGridView,它會將滾動條重置爲頂部。 我發現了一個使用FirstDisplayedScrollingRowIndex屬性的解決方案,但後來我意識到僅僅保存RowIndex是不夠的,我需要將我的注意力放在滾動上。我試圖谷歌它,並發現我需要使用面板。

我試過了,但我不知道如何將我的DGV綁定到Panel。 我在面板中移動它。添加代碼this.panel1.Controls.Add(this.DGV); 並將DGV.ScrollBars轉爲none。 我仍然沒有在面板上看到任何滾動條來滾動DGV中的數據。

解決方案我想:

Scrollbar loses focus when datagridview refreshs its content

Problem with DataGridView and scroll position

How can I set the position of my datagrid scrollbar in my winforms app?

回答

0

"I need to have a smooth elegant scroll on my DataGridView while it is updating\work".

VirtualizationStackPanel/VirtualizationPanel將有助於在加載基於滾動量數據網格項目。

http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingstackpanel.aspx http://msdn.microsoft.com/en-IN/library/system.windows.controls.virtualizingpanel(v=vs.90).aspx

still i don't see any scrolls on my panel, to scroll data in DGV

DGV.ScrollBarsnone將禁用電網滾動條。您可以嘗試之外插入一個ScrollViewer控制Panel

http://msdn.microsoft.com/en-us/library/ms750665.aspx

+0

你能請,表現出一定的代碼示例。我無法理解如何將其綁定到DGV。 –

+0

我使用Windows窗體,而不是WPF –