|
-
May 18th, 2013, 10:36 PM
#1
Thread Starter
New Member
need help wih radiobuttons
I am creating a program, how would it be possible to make the program show a certain video when i click on a certain radiobutton.
for example i have 1 button, 1 radiobutton, 3 pictures, 1 picturebox and 3 videos.
if i choose radiobutton 1 i want my picturebox to show pic 1 and for my button to show video 1 when i click it, when i choose radiobutton 2 i want my picturebox to show pic 2 and for my button to show video 2, etc. i know i can create a button for each video and create a listbox with each picture option using selected cases but i dont want to do that could any body help me?
-
May 19th, 2013, 11:24 AM
#2
Re: need help wih radiobuttons
You would need to store a value at the form level. This variable could be an integer, string, or better yet an enum. The video being played, as well as the picture to be displayed, by clicking your button would based on the value of that variable. Here is a quick example:
Code:
Option Strict On
Option Explicit On
Public Class Form1
'Just a custom enumeration
Private Enum FooEnum
Radio1
Radio2
Radio3
End Enum
'Here's my value
Private fooValue As FooEnum = FooEnum.Radio1 'Assuming radiobutton1's checked by default
Private Sub RadioButton_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton3.CheckedChanged, RadioButton2.CheckedChanged, RadioButton1.CheckedChanged
'Notice I handle RadioButton1,2, and 3's checkedchange event
If RadioButton1.Checked Then
fooValue = FooEnum.Radio1
ElseIf RadioButton2.Checked Then
fooValue = FooEnum.Radio2
Else
fooValue = FooEnum.Radio3
End If
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Select Case fooValue
Case FooEnum.Radio1
'Show picture1
'Play video1
Case FooEnum.Radio2
'Show picture2
'Play picture2
Case FooEnum.Radio3
'Show picture3
'Play picture3
End Select
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|