vb.net LED BOARD DISPLAY用户控件 [英] vb.net LED BOARD DISPLAY user control

查看:199
本文介绍了vb.net LED BOARD DISPLAY用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发vb.net中的LEDBOARD用户控件。我也做了。实际上它花了太多时间加载。在 vb6 相同的应用程序中我使用标签控件加载3000个标签数组,但不耗费时间。在 vb.net 我做的相同但加载3000个标签需要花费太多时间。是否还有其他方法(任何控件或任何自定义控件)来绘制输入文字(任何字体样式),图像如下图像
看起来如下

I am developing LEDBOARD user control in vb.net.I have done it also .Actually its taking too much time to load .In the vb6 same application I am loading 3000 labels using a label control array but not time consuming .In vb.net I am doing same but it's taking too much time to load 3000 labels.Is there any other way(any control or any custom control) to draw input text(any font style),image like below image It looks like below

推荐答案

通过继承 Control ,而不是使用UserControl并添加大量标签。

Create your LedBoard control from scratch by inheriting from Control, instead of using a UserControl and adding tons of labels.

我做了一个小测试,向您展示我的意思。您必须调整逻辑以满足您的需求。

I just made a little test to show you what I mean. You will have to adapt the logic to meet your needs.

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

这篇关于vb.net LED BOARD DISPLAY用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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