.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
vb.net 中MDI子窗体对其父窗体属性的获取与修改

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

   兄弟前些日子做项目,第一次使用vb.net,碰上不少问题,相信很多初学者多多少少都会遇到这些问题,为了初学者学习方便,小弟总结了一些小经验,供大家参考讨论。
第一篇:如何在MDI子窗体中控制父窗体的属性等等
    功能:比如打开一个子窗体后,就要设置父窗体中的某个菜单项或者按钮为不可见状态,诸如此类。
    内容:
MDI父窗体和MDI子窗体类定义如下:
MDI父窗体:
Class MDIForm
        Inherits System.Windows.Forms.Form
.........
        'member mnuMain  
        Friend WithEvents mnuEditPaste As System.Windows.Forms.MenuItem
.......
        'member  
        Friend WithEvents toolScan As System.Windows.Forms.ToolBarButton
        private sub showChild()
            dim frmTmp as new MDIChildFom'define a new instantce of MDIChildForm
            frmTmp.MdiParent = me                'set  the new form to be a Mdichild
            frmTmp.show()                                'show the new form
        end sub
end Class
MDI子窗体:
Class MDIChildForm
.......
   'set mnuEditPaste &  toolScan  cannot be seen 
   private sub setMDIMnuToolUnvisible()
        '***************************************'
        ' first method you can set a menuitem to be unvisible'
        '***************************************'
        'this method you could not control one  MenuItem
        'you can only set a group of menuitems
        me.MdiParent.Menu.Menuitems(0).visible = False       'set the first group menuitem can not be seen 
        'with this method you have not right to modify toolScan

        dim frmMdi as MDIForm
        if tyhpeof me.MdiParent  is MDIForm
            frmMdi = DirectCast(me.Mdiparent, MDIForm)'get the instantce of me.MdiParent
                                            'then you should access all the members of class MDIForm without private members
            frmMdi.mnuEditPaste  = False
            frmMdi.toolScan  = Flase
            'like this you could do everything with MDIForm you want
        end if
               
    end sub
end Class

       




相关文章

相关软件