Chapter Five LAB
Chapter Five LAB
Chapter Five LAB
B. Then the following dialog will appear so, look for MDI parent and select it.
C. After you add that item you will get the following, now you can customize.
Example
2. SaveFileDialog
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
With SaveFileDialog1
.DefaultExt = "txt"
.FileName = strFileName
.Filter = "Text Documents (*.txt)|*.txt|All Files
(*.*)|*.*"
.FilterIndex = 1
.OverwritePrompt = True
.Title = "Demo Save File Dialog"
End With
'Show the Save dialog and if the user clicks the Save button,
'save the file
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK
Then
Try
strFileName = SaveFileDialog1.FileName
My.Computer.FileSystem.WriteAllText(strFileName,
TextBox1.Text, False)
'Save the filepath and name
Catch ex As Exception
MessageBox.Show(ex.Message, My.Application.Info.Title,
_
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
End Class
3. FontDialog
Private Sub Button2_Click()
FontDialog1.ShowColor = True
'Show the Font dialog and if the user clicks the OK button,
'update the font and color in the text box
If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK
Then
TextBox1.Font = FontDialog1.Font
TextBox1.ForeColor = FontDialog1.Color
End If
End Sub
4. ColorDialog
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.BackColor = ColorDialog1.Color
End If