使用.NET 2 ListView的性能问题(错误?) [英] Performance issue (bug?) with .NET 2 ListView

查看:49
本文介绍了使用.NET 2 ListView的性能问题(错误?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET 2中的ListView是否有任何已知错误?我有一个应用程序需要15秒才能获得
的问题,现在

需要一分钟。有问题的代码使用:


listViewItem = this.listView1.Items.Add(...)

后跟7次调用


listViewItem.SubItems.Add(...)

当我注释掉这段代码时,应用程序在运行的同时运行/>
1.1版本。


有什么建议吗?如果需要,我可以提供源代码。

Are there any know bugs with the ListView in .NET 2? I''m having
problems with an application that takes 15 seconds in 1.1, and now
takes over a minute. The code in question uses:

listViewItem = this.listView1.Items.Add(...)

followed by 7 calls to

listViewItem.SubItems.Add(...)

When I comment out this code, the application runs in the same time as
the 1.1 version.

Any suggestions? I can provide the source code if required.

推荐答案

我建​​议:使用ListViewItem ctor,允许你指定

一次性使用子项,b:使用{Begin | End}更新语法(围绕

块) - 即

listview.BeginUpdate();

尝试{

ListViewItem newItem = new ListViewItem(new string [] {

" text1"," text2"," text3"," text4"});

listview.Items.Add(newItem);

//再次。 ..

//再次......

//再次......

//(或使用AddRange)

}终于{

listview.EndUpdate();

}


看看它是否更快。 ..你也可以尝试{暂停|恢复}布局。


Marc
I would suggest a: using the ListViewItem ctor that allows you to specify
the sub-items in one go, and b: using the {Begin|End}Update syntax (around a
block of such) - i.e.

listview.BeginUpdate();
try {
ListViewItem newItem = new ListViewItem(new string[] {
"text1","text2","text3","text4"});
listview.Items.Add(newItem);
// and again...
// and again...
// and again...
// (or use AddRange)
} finally {
listview.EndUpdate();
}

See if that works any quicker... you could also try {Suspend|Resume}Layout.

Marc


发生了什么。添加( ...)?

请发布一个完整的样本,说明问题,没有看到

任何代码都很难分辨出发生了什么。


威利。


<先生********* @ googlemail.com>在留言中写道

新闻:11 ********************** @ c74g2000cwc.googlegr oups.com ......

| .NET 2中的ListView是否有任何已知错误?我有

|应用程序的问题在1.1中需要15秒,现在是

|需要一分钟。有问题的代码使用:

|

| listViewItem = this.listView1.Items.Add(...)

|

|然后拨打7个电话给

|

| listViewItem.SubItems.Add(...)

|

|当我注释掉这段代码时,应用程序会在

|的同时运行1.1版本。

|

|有什么建议?如果需要,我可以提供源代码。

|
What''s happening in .Add(...)?
Please post a complete sample that illustraties the issue, without seeing
any code it''s hard to tell what''s happening.

Willy.

<mr*********@googlemail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
| Are there any know bugs with the ListView in .NET 2? I''m having
| problems with an application that takes 15 seconds in 1.1, and now
| takes over a minute. The code in question uses:
|
| listViewItem = this.listView1.Items.Add(...)
|
| followed by 7 calls to
|
| listViewItem.SubItems.Add(...)
|
| When I comment out this code, the application runs in the same time as
| the 1.1 version.
|
| Any suggestions? I can provide the source code if required.
|


在将项目添加到istview之前尝试添加子项* />

-

< mr ********* @ googlemail.com> schrieb im Newsbeitrag

新闻:11 ********************** @ c74g2000cwc.googlegr oups.com ...
try to add the subitems *before* you add the item to the istview

--
<mr*********@googlemail.com> schrieb im Newsbeitrag
news:11**********************@c74g2000cwc.googlegr oups.com...
.NET 2中的ListView是否有任何已知错误?我有一个应用程序的问题,在1.1中需要15秒,现在
需要一分钟。有问题的代码使用:

listViewItem = this.listView1.Items.Add(...)
接下来是7个调用

listViewItem .SubItems.Add(...)

当我注释掉这段代码时,应用程序会在1.1版本的同时运行。

任何建议?如果需要,我可以提供源代码。
Are there any know bugs with the ListView in .NET 2? I''m having
problems with an application that takes 15 seconds in 1.1, and now
takes over a minute. The code in question uses:

listViewItem = this.listView1.Items.Add(...)

followed by 7 calls to

listViewItem.SubItems.Add(...)

When I comment out this code, the application runs in the same time as
the 1.1 version.

Any suggestions? I can provide the source code if required.



这篇关于使用.NET 2 ListView的性能问题(错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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