关于VB.NET中MDI的问题 [英] Question about MDI in VB.NET

查看:50
本文介绍了关于VB.NET中MDI的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第三次试图发布此内容但从未在列表中看到它:

========================= ==========


在VB.NET中,我正在使用我的MDI应用程序进行以下操作..


请建议我是否会出现这种错误或有更好的方法。


我想,嗯,主要表格需要能够询问儿童表格是否

可以节省


所以我制作了以下界面。


''所有子表单实现ICanSave并返回true或false;因此主要可以

总是调用CanSave来查看它是否可以保存

公共接口ICanSave

ReadOnly属性CanSave()作为布尔值

结束界面


''如果可以保存,那么他们应该实现具有

跟随的ISave ...所以当用户点击Save icon ,这个Save方法''叫做

Public Interface ISave

函数IsDirty()As Boolean

函数Save()As Boolean

F. unination SaveAs(ByVal FileName As String)As Boolean

结束界面


主表格

Private Sub frmMain_MdiChildActivate(ByVal sender As对象,ByVal e As

System.EventArgs)处理MyBase.MdiChildActivate

Dim Savable作为ICanSave

Dim ISaver作为ISave

尝试

''看看是否可以保存

Savable = Me.ActiveMdiChild

如果Savable.CanSave那么

ISaver = Me.ActiveMdiChild

mnuFileSave.Enabled = ISaver.IsDirty

结束如果


mnuFileSaveAs.Enabled = Savable。 CanSave

Catch ex As Exception

''不知道如此禁用它们

mnuFileSave.Enabled = False

mnuFileSaveAs.Enabled = False

结束尝试

结束子


还有更好的方法吗?


我做的事情是愚蠢的吗?


是否有其他事件可以检查儿童表格变脏时因为我/ b $ b认为孩子激活需要点击。


那么我怎么知道何时启用Save图标呢?


希望这一切都有意义..


任何帮助表示赞赏。


Shane


3rd time trying to post this but never see it in the list:
===================================

In VB.NET, am doing the following with my MDI app..

Please advise if I am going about this wrong or there is a better way.

I thought, well, the main form needs to be able to ask the child form if it
can save

So I made the following interfaces.

''all child forms implement ICanSave and return true or false;main can thus
always call CanSave to see if it can save
Public Interface ICanSave
ReadOnly Property CanSave() As Boolean
End Interface

''if they can save they should then implement ISave which has the
following... So when user clicks Save icon, this Save method ''is called
Public Interface ISave
Function IsDirty() As Boolean
Function Save() As Boolean
Function SaveAs(ByVal FileName As String) As Boolean
End Interface

on main form
Private Sub frmMain_MdiChildActivate(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.MdiChildActivate
Dim Savable As ICanSave
Dim ISaver As ISave
Try
''see if can save
Savable = Me.ActiveMdiChild
If Savable.CanSave Then
ISaver = Me.ActiveMdiChild
mnuFileSave.Enabled = ISaver.IsDirty
End If

mnuFileSaveAs.Enabled = Savable.CanSave
Catch ex As Exception
''don''t know so disable them
mnuFileSave.Enabled = False
mnuFileSaveAs.Enabled = False
End Try
End Sub

Is there a better way?

Am I doing something dumb?

Is there another event to check when child form becomes dirty because I
think ChildActivate requires a click.

So how can I know when to enable the Save icon otherwise?

Hope this all makes sense..

Any help appreciated.

Shane


推荐答案

*" SStory" <钍******* @ TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:

[...]


打开''Option Strict On'',看看
$上的文档b $ b''DirectCast''运营商。


;-)

-

Herfried K.瓦格纳[MVP]

< http://www.mvps.org/dotnet>
* "SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
[...]

Turn on ''Option Strict On'', have a look at the documentation on the
''DirectCast'' operator.

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


我很抱歉这有什么关于MDI和

接口的问题?

如果我遵循一个好的设计技巧?没看到两者之间的关系

..

Shane


" Herfried K.瓦格纳[MVP]" <喜*************** @ gmx.at>在消息中写道

news:bp ************* @ ID-208219.news.uni-berlin.de ...
I''m sorry does that have anything to do with my question about MDI and
interfaces?
And if I am following a good desigin technique? Don''t see the relation
between the two..

Shane

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bp*************@ID-208219.news.uni-berlin.de...
*SStory <钍******* @ TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
[...]

打开''Option Strict On'',看看
''DirectCast''运营商的文档。 />
;-)

- Herfried K. Wagner [MVP]
< http://www.mvps.org/dotnet>
* "SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
[...]

Turn on ''Option Strict On'', have a look at the documentation on the
''DirectCast'' operator.

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>



*" SStory" <钍******* @ TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
* "SStory" <Th*******@TAKETHISSPAMBUSTEROUT.Softhome.net> scripsit:
对不起,这与我关于MDI和
界面的问题有什么关系?
如果我遵循一个好的设计技巧?没看到两者之间的关系..
I''m sorry does that have anything to do with my question about MDI and
interfaces?
And if I am following a good desigin technique? Don''t see the relation
between the two..



[...]


[...]

Turn在''Option Strict On'上,看看
''DirectCast''操作员的文档。
Turn on ''Option Strict On'', have a look at the documentation on the
''DirectCast'' operator.




如果你想要遵循一个好的编程技巧,你应该阅读我的

回复...


:-)


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>



If you want to follow a good programming technique, you should read my
reply...

:-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


这篇关于关于VB.NET中MDI的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆