Displaying The File Name

Windows Presentation Foundation User's Guide > Howto: Work With Files

It is convenient for the user to have the name of the file he or she is currently working with displayed as a window caption. One would normally use the FileName property of the file dialog box for this, but, as the dialog box is called from within Text Control, this option is not available.

This code sample shows how to get the filename by creating and passing a LoadSettings object as a parameter to the Load method.

private void mnuFile_OpenFile_Click(object sender, System.EventArgs e)
    TXTextControl.LoadSettings LoadSettings = new TXTextControl.LoadSettings();
    textControl1.Load(TXTextControl.StreamType.All, LoadSettings);
    this.Title = LoadSettings.LoadedFile;
[Visual Basic]
Private Sub mnuFile_OpenFile_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles mnuFile_OpenFile.Click
    Dim LoadSettings As New TXTextControl.LoadSettings()
    TextControl1.Load(TXTextControl.StreamType.All, LoadSettings)
    Me.Title = LoadSettings.LoadedFile
End Sub