【问题标题】:Problems when collapsing Treeview nodes in VB.net在 VB.net 中折叠 Treeview 节点时的问题
【发布时间】:2020-12-12 16:11:16
【问题描述】:

我在通过单击子节点打开表单然后关闭该表单时遇到 TreeView 问题(FormClosed 事件中确实包含 Me.Close() 和 Me.Dispose())。折叠父节点后出现问题,之前的表单再次打开。 表单从 Treeview AfterSelect 事件中打开。

    Private Sub TreeView1_AfterSelect(sender As Object, e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
    Dim rc%, i%

    Dim daFoodCat As New OleDbDataAdapter("Select * FROM tblFoodCategories INNER JOIN tblRecipes " & _
                                          "ON tblFoodCategories.RecipeID = tblRecipes.RecipeID " & _
                                          "ORDER BY RecipeName", cn)
    Dim dsRecipeName As DataSet = New DataSet
    daFoodCat.Fill(dsRecipeName, "tblFoodCategories")
    rc = dsRecipeName.Tables(0).Rows.Count

    For i = 0 To rc - 1
        If dsRecipeName.Tables(0).Rows(i).Item("RecipeName") = e.Node.Text Then
            rcpID = dsRecipeName.Tables(0).Rows(i).Item("tblRecipes.RecipeID")
        End If
    Next

    If rcpID = 0 Then
        'Do nothing
    Else
        frmRecipes.ShowDialog()
    End If


End Sub

【问题讨论】:

    标签: treeview vb.net-2010


    【解决方案1】:

    我通过在 frmRecipes.ShowDialog() 之后添加 rcpID = 0 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2020-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多