我正在 vb.net 中开发 LEDBOARD 用户控件。我也做过。实际上加载时间太长了。在vb6相同的应用程序中,我使用标签控件数组加载 3000 个标签,但不耗时。在vb.net我也在做同样的事情,但加载 3000 个标签需要太多时间。是否有任何其他方式(任何控件或任何自定义控件)来绘制输入文本(任何字体样式),图像如下图
它看起来像下面
问问题
1951 次
1 回答
1
通过继承 from 从头开始创建您的 LedBoard 控件Control
,而不是使用 UserControl 并添加大量标签。
我只是做了一个小测试来告诉你我的意思。您将不得不调整逻辑以满足您的需求。
Public Class LedBoard
Inherits Control
Private _rand As Random = New Random()
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
e.Graphics.FillRectangle(Brushes.Black, 0, 0, Width, Height)
Const nx As Integer = 40, ny As Integer = 25
Dim w = CInt((Width - 1) / nx) - 1
Dim h = CInt((Height - 1) / ny) - 1
For x As Integer = 0 To nx - 1
For y As Integer = 0 To ny - 1
If _rand.NextDouble() < 0.8 Then
e.Graphics.FillRectangle(Brushes.Red, x * (w + 1) + 1, y * (h + 1) + 1, w, h)
End If
Next
Next
End Sub
End Class
于 2011-12-23T19:34:54.723 回答