在 gridview/bindingsource 中重新排序记录
我正在使用 Telerik 的 WinForms 控件,并有一个 radGridView,它绑定到绑定源来显示我的数据。我想稍微扩展一下它的功能,为用户提供一种额外的方式来订购记录。
我在网格视图中添加了两个命令按钮(向上、向下)以帮助实现此功能。基本上,当单击“向上”按钮时,我希望当前行与上面的行交换位置;如果单击“向下”按钮,当前行应与下面的行交换位置。
示例数据:
1
2
3
4
5
如果单击第三行的“向上”按钮,数据应如下所示:
1
3
2
4
5
如果单击第三行的“向下”按钮,数据应如下所示:
1
2
4
3
5
我怎样才能实现这一目标?我是否必须修改这些行的绑定源位置或 gridview 行的索引?另一种方式?任何例子都非常感激!
I am using Telerik's WinForms controls and have a radGridView which is bound to a bindingsource to display my data. I would like to expand on the functionality of this a bit to give users an extra way to order the records.
I have added two command buttons to the gridview (Up, Down) to help facilitate this functionality. Basically, when the "Up" button is clicked, I would like the current row to switch places with the row above; if the "Down" button is clicked, the current row should switch places with the row below.
Example data:
1
2
3
4
5
If the "Up" button is clicked on the third row, the data should then look like so:
1
3
2
4
5
If the "Down" button is clicked on the third row, the data should look like this:
1
2
4
3
5
How can I achieve this? Do I have to modifiy the bindingsource positions of these rows, or the gridview row's index? Another way? Any examples are greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
决定使用拖放而不是向上/向下按钮。一切都很好。
Decided to use drag and drop instead of up/down buttons. All is well.