0

我有两个 ,一个RadioButtons用于,另一个Light Blue用于显示下一个表单()Ghost WhitebuttonForm2Radio Buttonbackcolor of form2Radio Button

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    SecondForm.Show()
    End Sub

Private Sub rbLightBlue_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbLightBlue.CheckedChanged
    If rbLightBlue.Checked Then
        SecondForm.BackColor = (Color.LightBlue)
    End If
End Sub

Private Sub rbGhostWhite_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbGhostWhite.CheckedChanged
    If rbGhostWhite.Checked Then
        SecondForm.BackColor = (Color.GhostWhite)
    End If
End Sub

我遇到的问题是在 Form2 上更改背景颜色。这个问题的任何答案都会非常有帮助。

4

1 回答 1

0

我不确定您在做什么,这可能与您创建 SecondForm 的方式有关,此代码确实有效,看看它是否可以帮助您缩小范围。

Public Class Form1
    Dim SecondForm As Form2 = New Form2
    Private Sub rbLightBlue_CheckedChanged(sender As Object, e As EventArgs) Handles rbLightBlue.CheckedChanged
        If DirectCast(sender, RadioButton).Checked Then
            SecondForm.BackColor = Color.LightBlue
        End If
    End Sub

    Private Sub rbGhostWhite_CheckedChanged(sender As Object, e As EventArgs) Handles rbGhostWhite.CheckedChanged
        If DirectCast(sender, RadioButton).Checked Then
            SecondForm.BackColor = Color.GhostWhite
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        SecondForm.Show()
    End Sub
End Class
于 2013-11-13T10:24:06.467 回答