1

いくつかのフォームを持つ VB.NET アプリケーションを作成しました。クリックするとサブフォームを開くいくつかのボタンがあるメインメニューがあります。私の問題は、サブフォームを開くと、メインフォームのボタンがサブフォームの前に表示されることです。

これらのボタンをサブフォームの後ろに置くにはどうすればよいですか?

見てみましょう:

ここに画像の説明を入力

メインメニューの完全なコードは次のとおりです。

Imports System.Windows.Forms

Public Class MDIParent1
    Private Declare Function AnimateWindow Lib "user32" (ByVal hwnd As Int32, ByVal dwTime As Int32, ByVal dwFlags As Int32) As Boolean
    Dim winHide As Integer = &H10000
    Dim winBlend As Integer = &H80000

    Private Sub NEWToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NEWToolStripMenuItem.Click
        ADD.MdiParent = Me
        ADD.Show()

    End Sub

    Private Sub EDITToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EDITToolStripMenuItem.Click
        EDIT.MdiParent = Me
        EDIT.Show()
    End Sub

    Private Sub CUSTOMERSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CUSTOMERSToolStripMenuItem.Click
        Cust_Det.MdiParent = Me
        Cust_Det.Show()
    End Sub

    Private Sub ITEMSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ITEMSToolStripMenuItem.Click
        Item_Det.MdiParent = Me
        Item_Det.Show()
    End Sub

    Private Sub CALCULATORToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CALCULATORToolStripMenuItem.Click
        Shell("calc.exe")
    End Sub

    Private Sub NOTEPADToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NOTEPADToolStripMenuItem.Click
        Shell("notepad.exe")
    End Sub

    Private Sub SEARCHToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SEARCHToolStripMenuItem.Click
        Search_Cust.MdiParent = Me
        Search_Cust.Show()
    End Sub

    Private Sub SEARCHITEMSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SEARCHITEMSToolStripMenuItem.Click
        Search_Item.MdiParent = Me
        Search_Item.Show()
    End Sub

    Private Sub BILLINGToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BILLINGToolStripMenuItem.Click
        BILLING.MdiParent = Me
        BILLING.Show()
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Dim msg
        msg = MsgBox("Are you sure you want to exit", MsgBoxStyle.YesNo, Me.Text)
        If msg = vbYes Then
            Me.Close()
        End If
    End Sub

    Private Sub ALLCUSTOMERSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ALLCUSTOMERSToolStripMenuItem.Click
        rpt = "cust"
        Dim obj As New Report
        obj.MdiParent = Me
        obj.Show()
    End Sub

    Private Sub ALLITEMSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ALLITEMSToolStripMenuItem.Click
        rpt = "item"
        Dim obj As New Report
        obj.MdiParent = Me
        obj.Show()
    End Sub

    Private Sub SALESPERDAYToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SALESPERDAYToolStripMenuItem.Click
        Sale_Rep.MdiParent = Me
        Sale_Rep.Show()
    End Sub

    Private Sub SETTINGToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SETTINGToolStripMenuItem.Click

    End Sub

    Private Sub MDIParent1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
        End
    End Sub

    Private Sub MDIParent1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            AnimateWindow(Me.Handle.ToInt32, CInt(500), winHide Or winBlend)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub MDIParent1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ToolStripStatusLabel1.Text = Date.Now

    End Sub

    Private Sub ChangeUserNameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeUserNameToolStripMenuItem.Click
        CHANGE_USER.MdiParent = Me
        CHANGE_USER.Show()
    End Sub

    Private Sub ChangePasswordToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangePasswordToolStripMenuItem.Click
        CHANGE_PASS.MdiParent = Me
        CHANGE_PASS.Show()
    End Sub

    Private Sub SEARCHBILLToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SEARCHBILLToolStripMenuItem.Click
        SEARCHBILL.MdiParent = Me
        SEARCHBILL.Show()
    End Sub

    Private Sub AboutUsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutUsToolStripMenuItem.Click
        about.Show()
    End Sub

    Private Sub ToolStripStatusLabel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub KEYBOARDToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KEYBOARDToolStripMenuItem.Click
        Shell("osk")
    End Sub

    Private Sub ViewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewToolStripMenuItem.Click

    End Sub

    Private Sub ToolStripStatusLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripStatusLabel1.Click

    End Sub

    Private Sub ToolStripStatusLabel2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ADD.MdiParent = Me
        ADD.Show()
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Dim msg
        msg = MsgBox("Are you sure you want to exit", MsgBoxStyle.YesNo, Me.Text)
        If msg = vbYes Then
            Me.Close()
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ADD.MdiParent = Me
        ADD.Show()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        EDIT.MdiParent = Me
        EDIT.Show()
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        BILLING.MdiParent = Me
        BILLING.Show()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Search_Cust.MdiParent = Me
        Search_Cust.Show()
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Search_Item.MdiParent = Me
        Search_Item.Show()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Cust_Det.MdiParent = Me
        Cust_Det.Show()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Item_Det.MdiParent = Me
        Item_Det.Show()
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        SEARCHBILL.MdiParent = Me
        SEARCHBILL.Show()
    End Sub

End Class

サブフォームの 1 つのコードは次のとおりです。

Imports System.Data.OleDb
Public Class ADD

    Public Sub clear1()
        txtiname.Text = Nothing
        txtimake.Text = Nothing
        txtirate.Text = Nothing
        txtiratio.Text = Nothing
        txtiunit.Text = Nothing

        numb()
    End Sub

    Public Sub clear()
        txtcname.Text = Nothing
        txtadd1.Text = Nothing
        txtadd2.Text = Nothing
        txtadd3.Text = Nothing
        txttel.Text = Nothing
        txtemail.Text = Nothing
        txtcst.Text = Nothing
        txttin.Text = Nothing
        txtstex.Text = Nothing

        numb()
    End Sub
    Private Sub cmdexit_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
        MDIParent1.Show()
    End Sub

    Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
        If con.State = ConnectionState.Open Then
            con.Close()
        End If

        Dim rs As String

        If txtcname.Text = "" Then
            MsgBox("Enter company name")
            Exit Sub
        End If
        Try
            rs = "INSERT INTO Customer_Master VALUES(@Cust_no,@Cust_name,@Cust_add1,@Cust_add2,@Cust_add3,@Cust_telephone,@Cust_Email_ID,@Cust_cstno,@Cust_tinno,@Cust_stexno)"
            Dim cmd As OleDbCommand = New OleDbCommand(rs, con)
            cmd.Parameters.AddWithValue("Cust_no", txtcno.Text)
            cmd.Parameters.AddWithValue("Cust_name", txtcname.Text)
            cmd.Parameters.AddWithValue("Cust_add1", txtadd1.Text)
            cmd.Parameters.AddWithValue("Cust_add2", txtadd2.Text)
            cmd.Parameters.AddWithValue("Cust_add3", txtadd3.Text)
            cmd.Parameters.AddWithValue("Cust_telephone", txttel.Text)
            cmd.Parameters.AddWithValue("Cust_Email_ID", txtemail.Text)
            cmd.Parameters.AddWithValue("Cust_cstno", txtcst.Text)
            cmd.Parameters.AddWithValue("Cust_tinno", txttin.Text)
            cmd.Parameters.AddWithValue("Cust_stexno", txtstex.Text)
            con.Open()
            Dim x As Integer = cmd.ExecuteNonQuery
            MessageBox.Show(x.ToString & "record added succesfully.........")
            con.Close()
            clear()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub cmdclr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclr.Click
        clear()
    End Sub

    Private Sub cmdexit1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit1.Click
        Me.Close()
    End Sub

    Private Sub cmdclr1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclr1.Click
        clear1()
    End Sub

    Private Sub cmdsave1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave1.Click
        If con.State = ConnectionState.Open Then
            con.Close()
        End If

        Dim rs As String
        If txtiname.Text = "" Then
            MsgBox("Enter Item name")
            Exit Sub
        ElseIf txtirate.Text = "" Then
            MsgBox("Enter Item rate")
            Exit Sub
        End If
        Try
            rs = "INSERT INTO Item_Master VALUES(@Item_no,@Item_name,@Item_make,@Item_rate,@Item_Ratio,@Item_Unit)"
            Dim cmd As OleDbCommand = New OleDbCommand(rs, con)
            cmd.Parameters.AddWithValue("Item_no", txtino.Text)
            cmd.Parameters.AddWithValue("Item_name", txtiname.Text)
            cmd.Parameters.AddWithValue("Item_make", txtimake.Text)
            cmd.Parameters.AddWithValue("Item_rate", txtirate.Text)
            cmd.Parameters.AddWithValue("Item_Ratio", txtiratio.Text)
            cmd.Parameters.AddWithValue("Item_Unit", txtiunit.Text)
            con.Open()
            Dim x As Integer = cmd.ExecuteNonQuery
            MessageBox.Show(x.ToString & "record added succesfully.........")
            con.Close()
            clear1()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub cmdexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit.Click
        Me.Close()
    End Sub

    Private Sub cmdedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdedit.Click
        EDIT.MdiParent = MDIParent1
        EDIT.Show()
    End Sub

    Private Sub cmdedit1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdedit1.Click
        EDIT.MdiParent = MDIParent1
        EDIT.Show()
    End Sub

    Private Sub ADD_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If con.State = ConnectionState.Open Then
            con.Close()
        End If

        Call numb()
    End Sub
    Public Sub numb()
        Dim cmdcno As New OleDb.OleDbCommand("select * from Customer_Master", con)
        Dim cmdino As New OleDb.OleDbCommand("select * from Item_Master", con)

        con.Open()

        Dim drcno As OleDb.OleDbDataReader = cmdcno.ExecuteReader
        Dim drino As OleDb.OleDbDataReader = cmdino.ExecuteReader

        While drcno.Read
            txtcno.Text = drcno(0)
        End While

        While drino.Read
            txtino.Text = drino(0)
        End While
        txtcno.Text = Val(txtcno.Text) + 1
        txtino.Text = Val(txtino.Text) + 1

        drcno.Close()
        drino.Close()
        con.Close()
    End Sub

    Private Sub txtirate_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtirate.TextChanged
        If IsNumeric(txtirate.Text) Or txtirate.Text = "" Then
        Else
            MsgBox("Enter numeric value")
            txtirate.Text = ""
        End If
    End Sub

    Private Sub txttel_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txttel.TextChanged
        If IsNumeric(txttel.Text) Or txttel.Text = "" Then
        Else
            MsgBox("Enter numeric value")
            txttel.Text = ""
        End If
    End Sub
End Class
4

1 に答える 1

2

あなたの条件に従って、

一時的に使用してフォームbringToFront()の を増やし、z-orderそれを前面に引き出すことができます。これを読んで、それを明確に理解してください。

于 2013-01-10T13:45:03.193 に答える