I’m working on building a List using Combobox that when a Client is selected from the combo list, it loads a specific URL. Problem is the List is blank.
Below is the code, but I don’t see what I’m missing but it could be simple oversight since this is the first time I’m building a Combobox like this.
public partial class Form1 : Form
{
List<MyClient> clients;
public Form1()
{
InitializeComponent();
clients = new List<MyClient>();
clients.Add(new MyClient { ClientName = "Client 1", UrlAddress = @"http://www.google.com" });
BindBigClientsList();
}
private void BindBigClientsList()
{
BigClientsList.DataSource = clients;
BigClientsList.DisplayMember = "ClientName";
BigClientsList.ValueMember = "UrlAddress";
}
private void BigClientsList_SelectedIndexChanged(object sender, EventArgs e)
{
MyClient c = BigClientsList.SelectedItem as MyClient;
if (c != null)
{
string url = c.ClientName;
Process.Start(url);
}
}
}
class MyClient
{
public string ClientName { get; set; }
public string UrlAddress { get; set; }
}
Your constructor should look like this
This adds two things: