机房收费系统-- MDI子窗体显示技巧(续vb.net版)

前端之家收集整理的这篇文章主要介绍了机房收费系统-- MDI子窗体显示技巧(续vb.net版)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在vb6.0版的机房收费系统中说道过这个问题,回顾请点击:http://www.jb51.cc/article/p-qcociuxt-vn.html这次在vb.net版本中想再次利用原先的代码,可是其中控件和语法都发生了一些小的变化,费了些周折,终于将这个问题解决了。

首先设置底衬窗体属性 FormBorderStyle=none

然后在父窗体加载时,同时加载底衬,并设置好大小

   Private Sub frmMain_Load(sender As Object,e As EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        frmCheckCard.MdiParent = Me
        frmCheckCard.Show()
        frmCheckCard.Width = Me.ClientRectangle.Width - 5
        frmCheckCard.Height = Me.ClientRectangle.Height - 30
    End Sub

每个子窗体都这样设置

Public Class frmShowOnlineRecord
    Private Sub frmShowOnlineRecord_Activated(sender As Object,e As EventArgs) Handles Me.Activated
        Dim a As Form
        For Each a In Application.OpenForms '遍历所有已经打开的窗体
            If a.Name <> frmCheckCard.Name And a.Name <> frmMain.Name And a.Name <> Me.Name Then
                a.WindowState = FormWindowState.Minimized '将除父窗体、底衬、本身之外的窗体最小化
                frmCheckCard.SendToBack() '并且,将底衬永远放在父窗体的z顺序的最底层
            End If
        Next
    End Sub

    Private Sub frmShowOnlineRecord_Load(sender As Object,e As EventArgs) Handles Me.Load
        Dim a As Form
        For Each a In Application.OpenForms
            If a.Name <> frmCheckCard.Name And a.Name <> frmMain.Name And a.Name <> Me.Name Then
                a.WindowState = FormWindowState.Minimized
                frmCheckCard.SendToBack()
            End If
        Next
    End Sub
End Class

每个子窗体都这样设置这个功能的实现,从全局出发,将每个打开的窗体遍历,找到该显示窗体的独特条件“Name”和actived 事件触发,以此限制了其他窗体的显示状体。

原文链接:https://www.f2er.com/vb/258578.html

猜你在找的VB相关文章