Visual Basic - 修改代码中生成的文本框和对象

发布于 2025-01-07 20:33:17 字数 185 浏览 0 评论 0原文

我编写了一个 for 循环来在应用程序运行时生成几个新的文本框和 numericUpDowns。

文本框/ numericUpDowns 是使用二维数组生成的。

我的问题是:当文本框/ numericUpDowns 被修改时如何处理?

如果您想要代码,只需请求它,我会将其添加到此处。

谢谢!

I've written a for loop to generate several new text boxes and numericUpDowns when the application is run.

The text boxes / numericUpDowns are generated with a 2-dimensional array.

My question is: How do I handle when the text boxes / numericUpDowns are modified?

If you would like the code, just request it and I'll add it here.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

装迷糊 2025-01-14 20:33:17

这是我为类似的事情写的东西。它制作了一个按钮网格并演示了如何处理事件。

Dim IsCreated(99) As Boolean
Dim Buttons As New Dictionary(Of String, Button)

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        For i As Integer = 0 To 99
            Dim B As New Button
            Me.Controls.Add(B)
            B.Height = 30
            B.Width = 40
            B.Left = (i Mod 10) * 41
            B.Top = (i \ 10) * 31
            B.Text = Chr((i \ 10) + Asc("A")) & i Mod 10 + 1
            Buttons.Add(B.Text, B)
            B.Tag = i
            AddHandler B.Click, AddressOf Button_Click
        Next


    End Sub

    Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim B As Button = sender
        IsCreated(B.Tag) = True
        B.BackColor = Color.Red
    End Sub

Here's something I wrote for something similar. It makes a grid of buttons and demonstrates how to handle the events.

Dim IsCreated(99) As Boolean
Dim Buttons As New Dictionary(Of String, Button)

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        For i As Integer = 0 To 99
            Dim B As New Button
            Me.Controls.Add(B)
            B.Height = 30
            B.Width = 40
            B.Left = (i Mod 10) * 41
            B.Top = (i \ 10) * 31
            B.Text = Chr((i \ 10) + Asc("A")) & i Mod 10 + 1
            Buttons.Add(B.Text, B)
            B.Tag = i
            AddHandler B.Click, AddressOf Button_Click
        Next


    End Sub

    Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim B As Button = sender
        IsCreated(B.Tag) = True
        B.BackColor = Color.Red
    End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文