needing some help creading a MDI text editor

Terabojin

Active member
Joined
Mar 4, 2012
Messages
33
Programming Experience
Beginner
I am greatly needing some assistance. I'm really unsure of how to do this.

Create an MDI text editor. Each child window should contain a multiline TextBox. The MDI parent should have a Format menu with submenus to control the size, font, and color of the text in the active child window. Each submenu should have at least three options. In addition, the parent should have a File menu with menu items New (create a new child), Close (close the active child), and Exit (exit the application). The parent should have a Window menu to display a list of the open child windows and their layout options.


I'm sure this is probably very easy for some, but I am completely lost with this. Any ideas?
 
Completely lost? So, you don't know how to add a menu to a form and items to that menu? You don't know how to add a TextBox to a form? You don't know how to make a form appears as an MDI child of another? You've been asked to do this task and you know absolutely nothing about anything it requires?
 
I dont know how to make a form apprear as an MDI child of another. I'm not sure how to code this so that the new page option works. I really have no idea what im doing to be honest.
 
ok im using that as a guilde however this is the 2003 version and im using the 2010 version.. when it says to set the Mdilist property to true, how would i do that in vb 2010. there isnt an option for that....
 
Any tutorial for VB.NET 2003 would have been using a MainMenu. That component still exists but has basically been superseded by the MenuStrip component. With a MenuStrip, the equivalent property is MdiWindowListItem. Given that it's the only member of the MenuStrip class that starts with "Mdi", that shouldn't have been too hard to work out.
 
I just created a brand new WinForms project and added a MenuStrip to the form and there was the MdiWindowListItem property in the Properties window, under the Behaviour section. It's the one named MdiWindowListItem.
 
To get much for free you can add the MDI Parent Form template instead of just the plain Form template.
 
ok here is the code that i have so far, but some of it isnt working yet and im not sure why (mostly the add window form to add a child)

Public Class parent
  
    Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
        Try
            Dim dlg As FontDialog = New FontDialog
            dlg.Font = RichTextBox1.Font
            If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
                RichTextBox1.Font = dlg.Font
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.Click
        RichTextBox1.Text = "" 'makes sure that the richtextbox is cleared out upon opening
        Try
            Dim dlg As ColorDialog = New ColorDialog
            dlg.Color = RichTextBox1.ForeColor
            If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then
                RichTextBox1.ForeColor = dlg.Color
            End If
        Catch ex As Exception
        End Try
    End Sub '
    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
        Dim ChildForm As New Child
        ChildForm.MdiParent = Me
        ChildForm.Show()
    End Sub
    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        'to save file
        Dim res As DialogResult
        Dim fname As String
        SaveFileDialog1.Filter = "Rich Text Format|*.rtf|Text File|*.txt"
        SaveFileDialog1.InitialDirectory = "C:\"
        res = SaveFileDialog1.ShowDialog()
        If res = Windows.Forms.DialogResult.OK Then
            fname = SaveFileDialog1.FileName
            'to save file
            'SaveFile method used to save file
            If SaveFileDialog1.FilterIndex = 1 Then
                'to save as RTF content
                RichTextBox1.SaveFile(fname)
            Else
                'to save as plain text
                RichTextBox1.SaveFile(fname, RichTextBoxStreamType.PlainText)
            End If
        End If
    End Sub
    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        Dim res As DialogResult
        OpenFileDialog1.Filter = "Rich Text Format| *.rtf|Text File|*.txt"
        'default directory
        OpenFileDialog1.InitialDirectory = "C:\"
        res = OpenFileDialog1.ShowDialog
        If res = Windows.Forms.DialogResult.OK Then
            If OpenFileDialog1.FilterIndex = 1 Then
            Else
                'RTF file selected
                RichTextBox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText)
            End If
        End If
    End Sub
   
    Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoToolStripMenuItem.Click
        RichTextBox1.Undo()
    End Sub
    Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RedoToolStripMenuItem.Click
        RichTextBox1.Redo()
    End Sub
    Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
        RichTextBox1.Cut()
    End Sub
    Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
        RichTextBox1.Cut()
    End Sub
    Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
        RichTextBox1.Paste()
    End Sub
    Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
        RichTextBox1.SelectAll()
    End Sub
    
    Private Sub FindToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindToolStripMenuItem.Click
        Dim strFind As String
        Dim pos As Integer
        strFind = InputBox("Enter String to find", "ICD")
        If strFind = "" Then
            Exit Sub
        End If
        RichTextBox1.Find(strFind)
        If pos = -1 Then
            MsgBox("String not found...")
        End If
    End Sub
End Class




also i cant figure out how to only close the child window once i do get it to open correctly.. please someone alive out there take a look?
 
Back
Top