0

so I'm doing a project where I need to set each item in a bombobox. example: Combobox in "Google" and "Facebook" just below the combobox has a webbrowser and when I press a button, the browser navigates to the desired link, I have done this part, appears the problem is that I do not know how to set the link for each item , to set www.google.com for Google option and even in facebook .. Can someone help me?

1 Answer 1

0

The combobox has 2 properties that you can use for this purpose. The DisplayMember is what you see in the GUI and the ValueMember is what you can use to navigate to based on the user selection. Example:

 Dim myDt As New DataTable() 'define a datatable to hold the combo box data Dim dt As New DataTable() dt.Columns.Add("Site") dt.Columns.Add("URL") '*** Load the combobox with data dt.Rows.Add("Google", "www.google.com") dt.Rows.Add("Facebook", "www.facebook.com") '***add other rows you might have here '*** now bind the datatable to the combobox ComboBox1.DataSource = dt ComboBox1.DisplayMember = "Site" 'for example Google ComboBox1.ValueMember = "URL" 'for example www.Google.com 

In your chosen event, afte the user selects an entry from the combobox, you could issue:

'***Launch the site that corresponds to the selected item in the combobox System.Diagnostics.Process.Start(ComboBox1.SelectedValue) 

You could use other means to initiate the navigation to selected site, for example: Open Web Page from App.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.