'宣言 Public Event RestoreTab As RestoreTabEventHandler
public event RestoreTabEventHandler RestoreTab
イベント ハンドラが、このイベントに関連するデータを含む、RestoreTabEventArgs 型の引数を受け取りました。次の RestoreTabEventArgs プロパティには、このイベントの固有の情報が記載されます。
プロパティ | 解説 |
---|---|
Form | タブに関連付けられたFormを取得または設定します。 |
Tab Infragistics.Win.UltraWinTabbedMdi.MdiTabEventArgsから継承されます。 | 関連付けられた MdiTab を返します。 |
WasVisible | 読み取り専用。タブがシリアル化されたとき、関連付けられたフォームが表示されていたかどうかを示します。 |
RestoreTab イベントは、LoadFromBinary(Stream) メソッドまたは LoadFromXml(Stream) メソッドが呼び出され、シリアル化された MdiTab オブジェクトがある時に起動されます。このイベントは、逆シリアル化されたタブを MDI 子フォームに関連付けるために呼び出されます。これは、RestoreTabEventArgs.Form プロパティを設定することによって行います。このプロパティが指定されていなければ、MdiTab は破棄されます。MdiTabの PersistedInfo プロパティを使用して、逆シリアル化時に関連付けるフォームに関する情報 (ファイル名など) を保存できます。
注: このイベント中に作成されたフォームは、関連付けられた MdiTab を持ちません。 このイベントに RestoreTabEventArgs.Form プロパティを設定するために使用されたフォームを作成できます。
Imports Infragistics.Win Imports Infragistics.Win.UltraWinTabs Imports Infragistics.Win.UltraWinTabbedMdi Private Sub ultraTabbedMdiManager1_RestoreTab(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTabbedMdi.RestoreTabEventArgs) Handles ultraTabbedMdiManager1.RestoreTab ' The 'RestoreTab' event is invoked during a call to ' LoadFromBinary or LoadFromXml when deserializing the ' serialized MdiTab objects. The event is invoked once ' for each serialized tab so that it may be associated ' with an mdi child. If the Form is not initialized the ' tab will be discarded. ' ' The 'PersistedInfo' can be used to store any serializable ' value. It is opaque to the tab and can be used to store ' information to help recreate the form that the tab should ' be associated with. ' Dim fileName As String = CType(e.Tab.PersistedInfo, String) ' By exiting without setting the 'Form' parameter, ' we're discarding the tab. If fileName = Nothing Or Not System.IO.File.Exists(fileName) Then Return End If ' Create the form that we will associate with the Tab. Normally ' whenever an mdi child form is created, an MdiTab is automatically ' created for the form but during the RestoreTab event, this will ' not happen so that new forms may be created to associate with ' a deserialized tab. ' Dim edit As EditForm = New EditForm() edit.FileName = fileName ' set the MdiParent property of the new form so it ' will be an mdi child form. Since the event could ' be caught somewhere other than the form class, we ' can access the MdiParent via the associated ' UltraTabbedMdiManager's MdiParent. edit.MdiParent = e.Tab.Manager.MdiParent ' The 'WasVisible' parameter indicates whether the tab ' was part of the HiddenTabs collection when the serialization ' took place. If the visible state is different, then the ' tab will be moved to/from the HiddenTabs collection to/from ' a tab group as needed. ' edit.Visible = e.WasVisible ' Set the 'Form' parameter so that the MdiTab will be ' associated with the form. e.Form = edit End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinTabs; using Infragistics.Win.UltraWinTabbedMdi; private void ultraTabbedMdiManager1_RestoreTab(object sender, Infragistics.Win.UltraWinTabbedMdi.RestoreTabEventArgs e) { // The 'RestoreTab' event is invoked during a call to // LoadFromBinary or LoadFromXml when deserializing the // serialized MdiTab objects. The event is invoked once // for each serialized tab so that it may be associated // with an mdi child. If the Form is not initialized the // tab will be discarded. // // The 'PersistedInfo' can be used to store any serializable // value. It is opaque to the tab and can be used to store // information to help recreate the form that the tab should // be associated with. // string fileName = e.Tab.PersistedInfo as string; // By exiting without setting the 'Form' parameter, // we're discarding the tab. if (fileName == null || !System.IO.File.Exists(fileName)) return; // Create the form that we will associate with the Tab. Normally // whenever an mdi child form is created, an MdiTab is automatically // created for the form but during the RestoreTab event, this will // not happen so that new forms may be created to associate with // a deserialized tab. // EditForm edit = new EditForm(); edit.FileName = fileName; // set the MdiParent property of the new form so it // will be an mdi child form. Since the event could // be caught somewhere other than the form class, we // can access the MdiParent via the associated // UltraTabbedMdiManager's MdiParent. edit.MdiParent = e.Tab.Manager.MdiParent; // The 'WasVisible' parameter indicates whether the tab // was part of the HiddenTabs collection when the serialization // took place. If the visible state is different, then the // tab will be moved to/from the HiddenTabs collection to/from // a tab group as needed. // edit.Visible = e.WasVisible; // Set the 'Form' parameter so that the MdiTab will be // associated with the form. e.Form = edit; }