自定义Datagridview ScrollBar问题 [英] Custom Datagridview ScrollBar problem

查看:139
本文介绍了自定义Datagridview ScrollBar问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我的Custom DataGridView上的ScrollBar出现问题.
我将自定义DGV插入了tabcontrol-tabpage并用行填充,并对其执行了自定义格式.
但是当我在选项卡之间切换并返回到原始选项卡时,滚动条变为脏"

http://picturepush.com/public/8478298
上图显示了我的Custom DGV,其中滚动条正常工作

http://picturepush.com/public/8478309 [

Hi.
Got an issue with ScrollBar on my Custom DataGridView.
I''ve inserted the custom DGV on a tabcontrol-tabpage and filled it with rows and performed my custom formatting on it.
But when I switch between tabs and return back to the original tab, the scroll bars go "dirty"

http://picturepush.com/public/8478298
The above picture shows my Custom DGV with the scrollbars working properly

http://picturepush.com/public/8478309[^]
This second picture shows the state of the scrollbar after I switched between the tabpages.

Why does this happen? Can someone help me out with a solution to this?

推荐答案

好吧...我找到了造成这种情况的原因. 由于我实现了多行点击(即一次单击就选择了3行),所以我使用clearselection()方法清除了先前的选择.

现在,问题出在clearselection()方法上,该方法导致滚动条变脏.如果删除了clearselection()语句,则滚动条在显示中不会损坏.

现在,出现了一个问题,为什么会这样?解决方法是什么?

注意:
1.我的clearselection()语句与选择行的代码一起在rowpostpaint()事件中.
2.不知何故,clearselection()事件不会调用任何绘画事件(如果我错了,请纠正我)
OK...I found out the cause for this.
Since I was implementing multiple row clicks (i.e. 3 rows being selected on one row click), I was using the clearselection() method to clear the previous selections.

The problem now lies with the clearselection() method that causes the scroll bars to get dirty. If I remove that clearselection() statement, there is no issue with the scrollbars getting corrupted in display.

Now, the question arises as to why is this happening? What is the workaround for it?

Note:
1. My clearselection() statement is in the rowpostpaint() event along with my code for selecting the rows.
2. Somehow the clearselection() event doesn''t call any of the paint events (correct me if I''m wrong)


这篇关于自定义Datagridview ScrollBar问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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