重新创建问题 [英] Re-Creating the Problem

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

问题描述

这是重新创建闪烁问题的简单方法。


- 创建一个新项目。

- 在表单上放置一个ListBox。 br />
- 调整大小以便它可以附带20个项目。

- 在表格上放一个按钮。

- 双击按钮添加一个Click事件处理程序。

- 在事件处理程序中插入以下代码:


{

TestListBox();

}


- 通过插入以下代码创建一个新方法:

private void TestListBox()

{

listBox1.BeginUpdate();


listBox1.Items.Clear();

for( int i = 0; i< 20; ++ i){

listBox1.Items.Add(" test");

}


listBox1.EndUpdate();

}


- 运行应用程序并单击按钮,在我的例子中查看项目被添加了可怕的闪烁效果的
:(

解决方案

你的第一个p ost说ListView现在你说ListBox这是否意味着你在两个控制器上都看到了这个?


不是我称你为骗子,但我没看到问题。


我是否向任一控件添加20或2000,不仅没有看到任何

闪烁,而且这些项目同时出现。我认为没有区别,如果我用
使用BeginUpdate / EndUpdate。


这是在我的1Ghz桌面和我的650Mhz笔记本电脑上。


排序怎么样,你打开排序了吗?这已知为

导致您描述的闪烁。在添加您的物品之前,请关闭分类

然后在添加物品后重新开启。

问候

Brian W



" C#Learner" < CS **** @ learner.here>在消息中写道

新闻:哦************** @ tk2msftngp13.phx.gbl ...

这里很简单重新创建我的闪烁问题的方法。

- 创建一个新项目。
- 在表单上放置一个ListBox。
- 调整大小以便它可以包含20个项目。 /> - 在表单上放一个按钮。
- 双击按钮添加Click事件处理程序。
- 在事件处理程序中插入以下代码:

{
TestListBox();
}
- 通过插入以下代码创建一个新方法:

private void TestListBox()
{
listBox1.BeginUpdate();

listBox1.Items.Clear();
for(int i = 0; i< 20; ++ i){
listBox1.Items.Add(" test");
}

listBox1.EndUpdate();
}
- 运行应用程序点击按钮,在我的情况下,看到添加了可怕的闪烁效果的项目:(



Brian W写道:

你的第一个帖子说ListView现在你说ListBox这是否意味着你在两个控件上都看到了这个?


是的。使用ListView会稍微恶化,但是使用ListBox也会发生闪烁



不是我称你为骗子,但我没看到一个问题。

我是否向任一控件添加20或2000,不仅没有看到任何
闪烁,而且这些项目一次全部出现。如果我不使用BeginUpdate / EndUpdate,我认为没有区别。

这是在我的1Ghz桌面和我的650Mhz笔记本电脑上。

如何排序,你打开了排序吗?众所周知,这会导致你描述的闪烁。在添加物品之前,请先关闭物品
然后在添加物品后再将其重新打开。


否 - 它没有打开。按照我原来帖子中的确切步骤

会导致闪烁。

问候
Brian W


C#Learner写道:


< snip>

排序怎么样,你呢?打开排序?众所周知,这会导致你描述的闪烁。在添加物品之前,请关闭分类
然后在添加物品后再将其重新打开。



否 - 它没有打开。按照我原来帖子中的确切步骤
导致闪烁。




似乎控件(ListBox或ListView)正在努力

/抽奖/项目。问题是,这只发生在.NET控件上。


Here''s a simple way to recreate my flicker problem.

- Create a new project.
- Put a ListBox on the form.
- Resize it so that it can accompany 20 items.
- Put a button on the form.
- Double-click the button to add a Click event handler.
- Insert the following code in the event handler:

{
TestListBox();
}

- Create a new method by inserting the following code:

private void TestListBox()
{
listBox1.BeginUpdate();

listBox1.Items.Clear();
for (int i = 0; i < 20; ++i) {
listBox1.Items.Add("test");
}

listBox1.EndUpdate();
}

- Run the app and click the button, to see, in my case, items being
added with a horrible flicker effect :(

解决方案

Your first post said "ListView" now you say "ListBox" Does this mean you are
seeing this on both controls?

Not that I''m calling you a liar, but I don''t see a problem.

Whether I add 20 or 2000 to either control, not only do I not see any
flicker but the items appear all at one time. And I see no difference if I
use BeginUpdate/EndUpdate or not.

This is on my 1Ghz desktop, and my 650Mhz laptop.

What about sorting, do you have Sorting turned on? This has been known to
cause the flicker you describe. Before adding your items turn sorting off
then after your items are added turn it back on.
Regards
Brian W


"C# Learner" <cs****@learner.here> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl...

Here''s a simple way to recreate my flicker problem.

- Create a new project.
- Put a ListBox on the form.
- Resize it so that it can accompany 20 items.
- Put a button on the form.
- Double-click the button to add a Click event handler.
- Insert the following code in the event handler:

{
TestListBox();
}

- Create a new method by inserting the following code:

private void TestListBox()
{
listBox1.BeginUpdate();

listBox1.Items.Clear();
for (int i = 0; i < 20; ++i) {
listBox1.Items.Add("test");
}

listBox1.EndUpdate();
}

- Run the app and click the button, to see, in my case, items being
added with a horrible flicker effect :(



Brian W wrote:

Your first post said "ListView" now you say "ListBox" Does this mean you are
seeing this on both controls?
Yes. It''s slightly worse with ListView, but flickering also happens
with ListBox.
Not that I''m calling you a liar, but I don''t see a problem.

Whether I add 20 or 2000 to either control, not only do I not see any
flicker but the items appear all at one time. And I see no difference if I
use BeginUpdate/EndUpdate or not.

This is on my 1Ghz desktop, and my 650Mhz laptop.

What about sorting, do you have Sorting turned on? This has been known to
cause the flicker you describe. Before adding your items turn sorting off
then after your items are added turn it back on.
No - it''s not turned on. Following the exact steps in my original post
causes flickering here.
Regards
Brian W



C# Learner wrote:

<snip>

What about sorting, do you have Sorting turned on? This has been known to
cause the flicker you describe. Before adding your items turn sorting off
then after your items are added turn it back on.



No - it''s not turned on. Following the exact steps in my original post
causes flickering here.



It seems that the controls (ListBox or ListView) are struggling to
/draw/ the items. The thing is, this only happens with .NET controls.


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

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