How can I use a HyperLink within a ListBox?

1

I want to make a HyperLink for each result that will appear within ListBox .

    private void listBox_SelectionMode(object sender, EventArgs e)
    {
        LogisticaServiceContractClient Logistica = new LogisticaServiceContractClient();

        var Autos = Logistica.RetornoRomaneioPostagemPorImagem(2, retornoList.ToArray());

        if (Autos != null)
        {
            Autos.ToList().ForEach(delegate(RetornoRomaneioPostagemDataContract naoRetornado)
            {
                clog.ArquivoLog("Autos nao retornados:", String.Format("Numero auto: {0}, Tipo notificacao: {1}", naoRetornado.Numero_Auto, naoRetornado.Tipo_Notificacao), "arq.txt");
                Autos_Invalidos.Items.Add(naoRetornado.Numero_Auto);
            });

            MessageBox.Show("Nao foi possivel efetiar o retorno");
        }
        else
        {
            MessageBox.Show("Autos retornados");
        }
    }
    
asked by anonymous 28.04.2015 / 17:33

1 answer

0

A simple and effective example of how to handle items like HyperLinks:

private ListBox _listBox1;

public void Initialize()
{
    MyObject myObject = new MyObject();
    myObject.DisplayName = "Google";
    myObject.URL = "http://www.google.com";

    _listBox1.Items.Add(myObject);
    _listBox1.DisplayMember = "DisplayName";
    _listBox1.SelectedIndexChanged += _ListBox1_SelectedIndexChanged;
}

private void _listBox1_SelectedIndexChanged(object pSender, EventArgs pArgs)
{
    MyObject myObject = (MyObject)_listBox1.SelectedItem;
    Process.Start(myObject.URL);
}
    
09.09.2015 / 13:14