Ecrire le programme qui permet de réaliser l'interface suivante:
Solution :
Public Class Form1
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
TextBox1.Text = String.Empty
TextBox2.Text = String.Empty
TextBox1.Focus()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Undo()
End If
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Cut()
End If
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Copy()
End If
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Paste()
End If
End Sub
Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).SelectAll()
End If
End Sub
Private Sub MainToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MainToolStripMenuItem.Click
If MainToolStripMenuItem.Checked Then
ToolStrip1.Visible = True
Else
ToolStrip1.Visible = False
End If
End Sub
Private Sub FormattingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FormattingToolStripMenuItem.Click
If MainToolStripMenuItem.Checked Then
ToolStrip2.Visible = True
Else
ToolStrip2.Visible = False
End If
End Sub
Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
CType(Me.ActiveControl, TextBox).Undo()
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
CType(Me.ActiveControl, TextBox).Cut()
End Sub
Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
CType(Me.ActiveControl, TextBox).Copy()
End Sub
Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
CType(Me.ActiveControl, TextBox).Paste()
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
TextBox1.Text = String.Empty
TextBox2.Text = String.Empty
TextBox1.Focus()
End Sub
End Class
Solution :
Public Class Form1
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
TextBox1.Text = String.Empty
TextBox2.Text = String.Empty
TextBox1.Focus()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Undo()
End If
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Cut()
End If
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Copy()
End If
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Paste()
End If
End Sub
Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).SelectAll()
End If
End Sub
Private Sub MainToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MainToolStripMenuItem.Click
If MainToolStripMenuItem.Checked Then
ToolStrip1.Visible = True
Else
ToolStrip1.Visible = False
End If
End Sub
Private Sub FormattingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FormattingToolStripMenuItem.Click
If MainToolStripMenuItem.Checked Then
ToolStrip2.Visible = True
Else
ToolStrip2.Visible = False
End If
End Sub
Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
CType(Me.ActiveControl, TextBox).Undo()
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
CType(Me.ActiveControl, TextBox).Cut()
End Sub
Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
CType(Me.ActiveControl, TextBox).Copy()
End Sub
Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
CType(Me.ActiveControl, TextBox).Paste()
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
TextBox1.Text = String.Empty
TextBox2.Text = String.Empty
TextBox1.Focus()
End Sub
End Class
Aucun commentaire:
Enregistrer un commentaire