Presentation on theme: "A window application ---to know Dialogs (Week 7) ~csdywang/ta.htm."— Presentation transcript:
A window application ---to know Dialogs (Week 7) ~csdywang/ta.htm
Open a file in textbox using OpenFileDialog
Step1 New a VB window application. Remember: the location must be local disk. Drag a textbox from toolbox, set its multiline=true and change its size. Drag a button and change the text=Open Drag an OpenFileDialog. (Page down Windows Forms in toolbox and you will find it!)
Step2 Double click the button Add: –White italic: codes you need to add –Yellow italic: codes that already exist Imports System.IO Imports System.Drawing.Printing before Public Class Form1 Inherits System.Windows.Forms.Form Inherits System.Windows.Forms.Form
Step 2 contd Add Private FileName1 As String before Private Sub Button1_Click(…) Private Sub Button1_Click(…)
Step 3 The script for open a file is in s1. Please open it with WordPad. Copy the codes and run the program. Open a.txt file with it. Remove some codes between Try With and End With. Then, see the result again. If you have any questions about properties and methods of some classes, just use F1 to see the help.
Save a file Drag one more button and a SaveFileDialog Copy the codes that were written in s2. Run the program
ColorDialog Drag ColorDialog and one more button. The codes for button3 are in s3. Copy them. Run and change the color of shown texts.
Other Dialogs File all contains more codes for more dialogs, such as PrintPreviewDialog etc. If you interest, try to implement them in your application.