【问题标题】:Cannot view Designer无法查看设计器
【发布时间】:2026-02-17 00:15:01
【问题描述】:

请帮忙!我的VB项目中无法查看控制参数调整表,其他三种正常。

我该如何解决这个问题?

这里是 Designer.vb 代码:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Control_Parameter_Adjustment
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.Label31 = New System.Windows.Forms.Label()
......
End Class

【问题讨论】:

  • 为什么不能“查看控制参数调整表”?有什么错误吗?
  • 另外,请记住,设计器在设置 UI 时会执行调用的代码,因此您的表单设置中不应调用的任何内容都应使用 If Not DesignMode Then .... End If
  • 您的.Designer 文件有问题...发布Control Parameter Adjustment.Designer.vb...的代码。截至目前,它将其视为一个类而不是一个表格.
  • @Xi Wang 你的班级好像有空格,不能有空格。你修改了这些?例如:Control Parameter Adjustment ***应该是 Control_Parameter_Adjustment...您的设计器文件的名称中确实包含 _,但您在树中的类没有显示这些...您还缺少 Me.SuspendLayout()InitializeComponent 子和Me.ResumeLayout(False)...
  • 问题不一定是*.Designer.vb文件,也可能是项目文件。尝试从项目中删除表单及其文件(但不是从磁盘中!),然后将它们重新导入项目。

标签: vb.net winforms designer


【解决方案1】:

首先,我为我糟糕的英语道歉。

这对我有用:如果您在项目中添加一个空表单,您可以双击它,您可以看到以下内容:

Public Class Form1

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

End Sub

End Class

你看不到其他形式的类定义,可能是因为这个类已经消失(我无法解释为什么)。

此外,您可能还可以在表单代码中找到 form_Load 事件。

只需重写该类,更改类定义中的表单名称。然后,你可以看到设计师。图标也会改变。

【讨论】: