If (Combox.text == "ONYX") a separate combo box items get filled using a pastebin raw (C# .NET)

122 Views Asked by At

I'm trying to make it so when a separate Combobox.text = "ONYX" Other Combobox items will be imported using Pastebin raw.

Example:

  if (api1.Text == "ONYX")`

methods1.Items.Add(new WebClient().DownloadString("https://pastebin.com/raw/B7nFQpQ3"));

I tried using an Addrange instead

(new WebClient().DownloadString("https://pastebin.com/raw/B7nFQpQ3"));`

The add range came Out Having the whole WebClient code as an error.

1

There are 1 best solutions below

1
Ryan Thomas On

I assume you want to split the items by line and add those items. Try this.

if (api1.Text == "ONYX")
{
    var downloadedString = new WebClient().DownloadString("https://pastebin.com/raw/B7nFQpQ3");
    var itemsSplit = downloadedString.Split('\r');
    comboBox1.Items.AddRange(itemsSplit);
}