Vb.net Net文本可见性

Vb.net Net文本可见性,vb.net,Vb.net,我想更改某些文本的可见性,但我的代码无法更改。我没有发现任何错误。我的代码是: Public Class Form1 Private Property Ay1TarihLabel As Object Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'SatisData

我想更改某些文本的可见性,但我的代码无法更改。我没有发现任何错误。我的代码是:

Public Class Form1

    Private Property Ay1TarihLabel As Object

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'SatisDataSet.SatisT' table. You can move, or remove it, as needed.
        Me.SatisTTableAdapter.Fill(Me.SatisDataSet.SatisT)

        Ay1TarihLabel.Visible = False

    End Sub

End Class

我做错了什么?

您应该针对真实标签调用.visible=false,如果您在designer模式下这样做,您将寻找:
Friend with Events AY1将标签标记为System.Windows.Forms.Label

或者类似的。您可以在加载时设置visible=false。

设置断点a
Me.SatisTTableAdapter.Fill
并查看是否真的到达
ay1tarhilabel.visible=false
。如果没有,则在调试器的“快速监视”窗口中执行
Fill
。然后检查返回的
Me.SatisDataSet.SatisT.GetErrors()
行。每一行都有一个
RowError
属性,这会导致出现问题。或者,如果表单尚未可见,则该行代码将不起任何作用。您可以在设计时进行设置,也可以在另一个表单事件中进行设置,这可能会有所帮助。谢谢你的回复。当我设置断点时,我得到的是Ay1TarihLabel Nothing对象。我不知道如何使用GetErrors()@nikel:您将
ay1tarilabel
声明为
Object
,但在哪里初始化它?你为什么要手动声明它?@nikel:为什么不在designer中添加带有正确
名称的标签?然后它会自动创建。是的,我是在设计器模式下创建的。我是VB.Net新手,我将把Friend WithEvents Ay1TarihLabel放在哪里作为System.Windows.Forms.Label只是用它替换私有属性行,但是如果你在设计器模式下这样做,它应该已经在代码中了,搜索你的Ay1TarihLabel解决方案