C#窗口窗体同步滚动显示2格网视图 [英] C# windows form 2 gridviews with synced scroll
问题描述
任何人都可以告诉我如何或直接我很好的教程。
如果你有dgv1和dgv2,你可以创建一些类似于
dgv1.Scroll + = new System.Windows.Forms.ScrollEventHandler(dgv1_Scroll);
然后,在dgv1_Scroll方法中,您可以使用FirstDisplayedScrollingRowIndex属性:
dgv2.FirstDisplayedScrollingRowIndex = dgv1.FirstDisplayedScrollingRowIndex
当然,如果dgv具有不同的行数,则需要通过检查每个dgv行数来避免IndexOutOfRange异常。
I am developing an application in which two datagridviews are being populated from different data sources. I would like to have a single vertical scroll-bar that will make both gridviews work at the same time (scroll up and down together)
can anyone tell me how or direct me to a good tutorial.
If you have dgv1 and dgv2, you can create something like
dgv1.Scroll += new System.Windows.Forms.ScrollEventHandler(dgv1_Scroll);
Then, in dgv1_Scroll method, you can use FirstDisplayedScrollingRowIndex property:
dgv2.FirstDisplayedScrollingRowIndex = dgv1.FirstDisplayedScrollingRowIndex
Of course, if dgv's have different ammount of rows, you need to avoid IndexOutOfRange exception by checking each dgv rows count.
这篇关于C#窗口窗体同步滚动显示2格网视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!