Presentation is loading. Please wait.

Presentation is loading. Please wait.

A short ppt Importing images Changing fonts. Getting images.

Similar presentations


Presentation on theme: "A short ppt Importing images Changing fonts. Getting images."— Presentation transcript:

1 A short ppt Importing images Changing fonts

2 Getting images

3 Combobox & image.fromFile

4 Combo box Select the collection property to populate the combo box I used Picturebox.image=image.fromfile(“C:\penguin.gif”); My combobox selected index changed sub code is below: If cbbchoose.Text = "dog" Then pb.Image = Image.FromFile("c:\dog.gif") ElseIf cbbchoose.Text = "bear" Then pb.Image = Image.FromFile("c:\bear.gif") Else pb.Image = Image.FromFile("c:\penguin.gif") 'pb.Refresh() End If Note: I didn’t take time to figure out how to get it to look in the application directory

5 Changing fonts via button press

6 I didn’t figure out how to get a font literal in this application

7 code Private Sub btnfont3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfont3.Click lbldisplay.Font = btnfont3.Font() End Sub Private Sub btnfont1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfont1.Click lbldisplay.Font = btnfont1.Font() End Sub Private Sub btnfont2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfont2.Click lbldisplay.Font = btnfont2.Font() End Sub

8 Literal font names

9 Press button to change font

10 code Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click Dim f As New System.Drawing.Font("Arial", 10) ' Assign the font to the control lbl1.Font = f ' To set additional properties, you must create a new Font object. lbl1.Font = f 'lbl1.Font = New System.Drawing.Font(lbl1.Font, FontStyle.Bold Or FontStyle.Italic) End Sub Private Sub Btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn2.Click Dim f As New System.Drawing.Font("Symbol", 12) lbl1.Font = f ' or use... 'lbl1.Font = New System.Drawing.Font(f, FontStyle.Bold) End Sub Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click Dim f As New System.Drawing.Font("SansSerif", 12) lbl1.Font = f lbl1.Font = New System.Drawing.Font(lbl1.Font, FontStyle.Underline) End Sub

11 Image.fromfile(“P:\...”) does work in F306 lab: a screenshot

12 Code for previous slide Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load PictureBox1.Image = Image.FromFile("p:\africa1.jpg") End Sub


Download ppt "A short ppt Importing images Changing fonts. Getting images."

Similar presentations


Ads by Google