|
-
May 5th, 2013, 10:57 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Combobox dropdown
Rephrasing Question:
In simple terms when I open the dropdown box and see a list of words e.g. Car version 1, Car version 2 etc I want to be able to click Car version 5 for example and that will take me to a website and the same for any other link. I dont want to see the website link in the dropdown list. The website is added in the code against the keyword. Thank you.
Last edited by jokerfool; May 6th, 2013 at 01:23 PM.
-
May 5th, 2013, 11:08 AM
#2
Addicted Member
Last edited by MetalInquisitor; May 5th, 2013 at 12:33 PM.
Reason: didn't understand the question
-
May 5th, 2013, 11:19 AM
#3
Re: Combobox dropdown
So that's fill the combobox with website addresses and navigate to anyone that's selected using the webbrowser control. What's the complication?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
May 5th, 2013, 11:23 AM
#4
Thread Starter
Hyperactive Member
Re: Combobox dropdown
Im new to this and dont know how to add the control to the list. So if I have the word Google in the list and you select it, then it displays Google.
-
May 5th, 2013, 11:27 AM
#5
Addicted Member
Re: Combobox dropdown
Try something like this:
vb.net Code:
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Load urls in the combobox ComboBox1.Items.Add("http://www.google.com") ComboBox1.Items.Add("http://www.vbforums.com") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'go to selected combobox url in webbrowser1 WebBrowser1.Navigate(ComboBox1.SelectedItem) End Sub End Class
-
May 5th, 2013, 11:54 AM
#6
Thread Starter
Hyperactive Member
Re: Combobox dropdown
So I got this to work, but this isn't what I am looking for. When I access the dropdown list I need to see the word Google, not the website, plus when I select the website addy I need it to load outside the form, not in a browser in the application, can you help me with this please?
-
May 5th, 2013, 12:16 PM
#7
Addicted Member
Re: Combobox dropdown
You could create a class which would have a Name and URL properties. In Name you would have "Google" and in URL you would have "http://www.google.com". You create objects of this class, add their respective Name and URL properties and then add them to the ComboBox. The ComboBox's DisplayMember would be Name so that the CB displays the items' Name in the dropdownlist and the ValueMember would be URL.
When you select an item from the CB and click a button, you could use Process.Start to start Firefox and the CB.SelectedItem's value member to tell it what URL to open.
There's probably a simpler way but I'm also still learning the basics of VB.NET.
-
May 5th, 2013, 12:30 PM
#8
Re: Combobox dropdown
you could use a dictionary(of string, string), with the keys being Google, VBForums, etc, + the values being the associated urls:
Code:
Public Class Form1
Dim items As New Dictionary(Of String, String)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
items.Add("Google", "http://www.google.com")
items.Add("VBForums", "http://www.vbforums.com")
ComboBox1.Items.AddRange(items.Keys.ToArray)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Process.Start(items(ComboBox1.Text))
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 6th, 2013, 03:36 AM
#9
Thread Starter
Hyperactive Member
Re: Combobox dropdown
Please read first post, changed the question. Thank you.
-
May 6th, 2013, 06:53 AM
#10
Re: Combobox dropdown
 Originally Posted by jokerfool
Please read first post, changed the question. Thank you.
paul's code should do what you're seeking to do.
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
|