当用户在DataGridView中对列重新排序时,如何允许自动滚动到未显示的列 [英] How can I allow automatic scrolling to columns that are not displayed while the user is reordering columns in DataGridView

查看:107
本文介绍了当用户在DataGridView中对列重新排序时,如何允许自动滚动到未显示的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用无数据绑定 DataGridView (与C#,VS2008)来显示跨多达20列的表格数据.显然,只有一小部分列可以显示在屏幕上.该应用程序必须允许用户对列进行重新排序,并且我启用了DataGridView控件的 AllowUserToOrderColumns 属性.但是,我无法自动控制水平滚动条,以便用户可以轻松地拖放列.

谁能给我指出解决该问题的方法.有人可以给我一些想法,如何构建自己的自定义DataGridView控件,该控件支持自动水平滚动的列重新排序.
Yon

Hi,
I am using a none data bound DataGridView (with C#, VS2008)to display a tabular data that spans up to 20 columns. Obviously, only small portion of the columns can be displayed on the screen. The application must allow the user to reorder the columns and I enabled the AllowUserToOrderColumns property of the DataGridView control. However, I cant automatically control the horizontal scroll bar so that users can drag and drop columns easily.

Can any one point me to the remedy for the problem.Can someone please give me some idea how to build my own custom DataGridView control that support Column Reordering with auto horizontal scrolling.
Yon

推荐答案

我从您的问题中了解到的是,您希望GridView在选择列并将其拖到最后一个可见列时自动滚动. >
为此,您可以在CellMouseEnter/Move事件中编写代码,并检查当前列是否最后可见.您可以通过
进行检查
FirstDisplayedScrollingColumnIndex属性,还可以设置新值.
What I understood from your problem is that you want the GridView to auto scroll when you selects a column and drag it past to last visible column.

To do this , you can write code in CellMouseEnter/Move event and check that current column is last visible. You can check it by

FirstDisplayedScrollingColumnIndex property and also can set new value.


非常感谢,但是我已经尝试过了,问题是网格仍然无法轻松地来回滚动
thank you very much but I have tried this and the problem is the grid still do not scroll easily back and forth


这篇关于当用户在DataGridView中对列重新排序时,如何允许自动滚动到未显示的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆