列表视图中的闪烁问题 [英] Flickering problem in listview

查看:120
本文介绍了列表视图中的闪烁问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了很多谷歌搜索,但我没有得到正确的解决方案,以阻止在listview中闪烁,因为我在richtextbox中停止闪烁,但我没有停止在列表视图中闪烁。



以下代码我以前在Richtexbox中停止闪烁...它对我有用..



 [System.Runtime。 InteropServices.DllImport(  user32.dll)] 
private extern static IntPtr SendMessage( IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);

// 每2秒后重新加载代码...

SendMessage(RichText_MessageData.Handle,0xb,( IntPtr 0 IntPtr的 .Zero);
// 在richtextbox中进行一些更改...

SendMessage(RichText_MessageData.Handle,0xb,( IntPtr 1 IntPtr的 .Zero);
RichText_MessageData.Invalidate();







我使用下面的代码来停止闪烁在listview中.....它没有用..

 SendMessage(lv_employeelist.Handle,0xb,( IntPtr  0  IntPtr  .Zero); 
// 每2秒在listview中添加一行..
SendMessage( lv_employeelist.Handle,0xb,( IntPtr 1 IntPtr .Zero);
lv_employeelist.Invalidate();





我在这做错了什么...

解决方案

您好,您可能需要考虑运行代码以在单独的线程中将UI更新为主执行线程。



之前我遇到过与Winforms类似的问题,并且发现您描述的闪烁行为通常是在您尝试在执行其他操作时更新UI时引起的。

I have do lots googling but I did not get right solution to stop flickering in listview as I am stop flickering in richtextbox but I did not stop flickering in listview.

following code I used to stop flickering in Richtexbox...it is works for me..

[System.Runtime.InteropServices.DllImport("user32.dll")]
        private extern static IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);

//below code reloaded after every 2 seconds...

SendMessage(RichText_MessageData.Handle, 0xb, (IntPtr)0, IntPtr.Zero);
//doing some changes in richtextbox...

SendMessage(RichText_MessageData.Handle, 0xb, (IntPtr)1, IntPtr.Zero);
            RichText_MessageData.Invalidate();




and I am using below code to stop flickering in listview.....It is not worked..

SendMessage(lv_employeelist.Handle, 0xb, (IntPtr)0, IntPtr.Zero);
//adding rows in listview in every 2 seconds..
SendMessage(lv_employeelist.Handle, 0xb, (IntPtr)1, IntPtr.Zero);
            lv_employeelist.Invalidate();



What I am done here wrong...

解决方案

Hi, you might want to consider running code to update your UI in a separate thread to the main thread of execution.

I have experienced similar problems with Winforms before and have found that the flickering behaviour you described is usually caused when you're trying to update your UI whilst performing another operation.


这篇关于列表视图中的闪烁问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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