表格支持多少个标签? [英] How many lables can a form suport ?

查看:99
本文介绍了表格支持多少个标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在那里,我正在开发一个使用4种形式的应用程序。

当我尝试打开我的

第三种形式时,每种形式都有大约2000种标签,一个错误的错误,但没有出现错误消息。

我已经意识到,如果我尝试创建一个表单集合

喜欢:


子测试()

Dim f as new Form1

f.show

end sub


如果form1有300个标签而没有其他控件,

程序挂起,当第33个表格出现时(大约9900

标签)。


它适用于VB6.0


我该怎么做才能解决这个问题?


谢谢

解决方案

*" Peter" < PC **** @ spc.sapec.pt> scripsit:

在那里,我正在开发一个使用4种形式的应用程序。
当我尝试打开我的第三种形式时,每种形式都有大约2000种标签,错误ocurrs,但没有出现错误消息。
我已经意识到,如果我尝试创建一个表单集合
如下:

sub Test()
Dim f如新的Form1
f.show
end sub

如果form1有300个标签而没有其他控件,那么当第33个表单出现时,
程序会挂起(大约9900
标签)。

它在VB6.0中工作




VB6中的标签是无窗口控件,并没有需要很多内存。

..NET标签是windows。使用任务管理器查看

应用程序的内存使用情况。


-

Herfried K. Wagner

MVP·VB Classic,VB.NET

< http://www.mvps.org/dotnet>


< BLOCKQUOTE>"彼得" < PC **** @ spc.sapec.pt> schrieb

在那里,我正在开发一个使用4种形式的应用程序。
每个表单都有大约2000个标签,当我尝试打开我的第三个表单时出错ocurrs,但没有出现错误消息。
我已经意识到,如果我尝试创建一个表单集合
如下:

子测试()
昏暗的f如果新的Form1
f.show
结束子

如果form1有300个标签而没有其他控件,
程序会挂起,当出现第33个表格时(关于9900
标签)。

它在VB6.0中工作

我该怎么做才能解决这个问题?



我猜你得到的是System.ComponentModel.Win32Exception?那是我得到的

。在代码周围放置一个try-catch块并捕获异常。

NativeErrorCode属性返回14. MSDN说:


14 |没有足够的存储空间来完成此操作。 |

ERROR_OUTOFMEMORY


一种解决方案:不要使用标签。相反,通过覆盖来绘制文本

OnPaint。


如果你还使用其他控件如Textboxes,我会考虑使用网格,
就像DataGrid一样。


-

Armin


嗨彼得,


当我看到Armin的答案时,我明白了这个想法,


为什么你不使用一个标签和用stringbuilder填充,而

同时增加高度?


只是一个想法?


Cor


hi there, i''m developing an aplication that uses 4 forms.
Each form has about 2000 labels, when I try to open my
third form, an error ocurrs, but no error mesage appears.
I''ve realised that if I try to crate a form collection
like:

sub Test()
Dim f as new Form1
f.show
end sub

and if form1 has 300 labels and no other controls, the
program hangs, when the 33rd form appears (about 9900
labels).

It worked in VB6.0

What can I do to work this Out ?

Thanks

解决方案

* "Peter" <pc****@spc.sapec.pt> scripsit:

hi there, i''m developing an aplication that uses 4 forms.
Each form has about 2000 labels, when I try to open my
third form, an error ocurrs, but no error mesage appears.
I''ve realised that if I try to crate a form collection
like:

sub Test()
Dim f as new Form1
f.show
end sub

and if form1 has 300 labels and no other controls, the
program hangs, when the 33rd form appears (about 9900
labels).

It worked in VB6.0



Labels in VB6 were windowless controls and didn''t need much memory.
..NET labels are windows. Have a look at the memory usage for the
application with the task manager.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>


"Peter" <pc****@spc.sapec.pt> schrieb

hi there, i''m developing an aplication that uses 4 forms.
Each form has about 2000 labels, when I try to open my
third form, an error ocurrs, but no error mesage appears.
I''ve realised that if I try to crate a form collection
like:

sub Test()
Dim f as new Form1
f.show
end sub

and if form1 has 300 labels and no other controls, the
program hangs, when the 33rd form appears (about 9900
labels).

It worked in VB6.0

What can I do to work this Out ?



I guess you are getting a System.ComponentModel.Win32Exception? That''s the
one I get. Put a try-catch block around your code and catch the exception.
The NativeErrorCode property returns 14. MSDN says:

14 | Not enough storage is available to complete this operation. |
ERROR_OUTOFMEMORY

One solution: Don''t use labels. Instead, paint the text by overriding
OnPaint.

If you also use other controls like Textboxes, I''d consider using a grid,
like the DataGrid, instead.

--
Armin


Hi Peter,

I got this idea when I saw the answer from Armin,

Why do you not use one label and fill that with stringbuilder, while
increasing the hight in the same time?

Just an idea?

Cor


这篇关于表格支持多少个标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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