VB条带菜单MDI父级禁用MDI子问题

时间:2014-12-03 09:38:46

标签: vb.net visual-studio-2010 mdiparent

我在VB中需要一些帮助。我今天刚开始学习vb。

所以我有一个MDIParent表单,其中包含登录,注销(禁用)和其他禁用的条带菜单。

所以当我点击登录时,登录表单显示为MDI子窗口。

问题是,当我成功登录时,我想禁用登录条带菜单,启用注销条状菜单和其他条带菜单。我试过这个。现在这是我的代码:

Imports MySql.Data.MySqlClient

公共类LoginForm

Dim mdiP As New MDIParent
Dim myconn As New MySqlConnection("Server=localhost; User Id=root; Password=; Database=apotek_db")


Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

    If UsernameTextBox.Text = "" Or PasswordTextBox.Text = "" Then
        MsgBox("Please insert username and password")
    End If

    Dim username As String = UsernameTextBox.Text
    Dim password As String = PasswordTextBox.Text

    Dim myAdapter As New MySqlDataAdapter("select * from admin where USERNAME = '" & username & "' and PASSWORD = '" & password & "'", myconn)
    Dim myDataTable As New DataTable
    myAdapter.Fill(myDataTable)

    If myDataTable.Rows.Count < 1 Then
        PasswordTextBox.Clear()
        UsernameTextBox.Clear()
        MsgBox("Invalid username or password")

    Else
        MsgBox(username & " Successfully logged in")
        mdiP.logOutMenu.Enabled = True
        mdiP.logInMenu.Enabled = False
        mdiP.TransaksiPenjualanToolStripMenuItem.Enabled = True
        mdiP.DataObatToolStripMenuItem.Enabled = True
        Me.Close()
    End If




End Sub

Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
    mdiP.Show()
    Me.Close()
End Sub

结束班


但上面的代码并没有禁用或启用MDI父级中的任何内容。它只是显示消息框而不是我成功登录,并关闭登录表单。就是这样。

所以任何人都有解决方案吗?

提前致谢,

Rezz。

0 个答案:

没有答案