简体   繁体   中英

How to output only a part of values from ListBox?

I would like to output only a part of items from listBox1 like: response.response.items[counter].first_name to lable_name.Text . How can I do that?

Part of method:

for (int counter = 0; counter < response.response.items.Count; counter++)
{
    listBox1.Items.Add(response.response.items[counter].first_name + " " + response.response.items[counter].last_name  + Environment.NewLine);
}

The way I output items to lable:

private void listBox1_DoubleClick(object sender, EventArgs e)
{
    int count = listBox1.Items.Count -1;

    for (int counter = count; counter >= 0; counter--)
    {
        if (listBox1.GetSelected(counter))
        { 
            lable_name.Text= listBox1.Items[counter].ToString();
        }
    }
}
lable_name.Text = listbox1.Items[counter].ToString().Split(' ')[0];

could be one of the options ...

just make sure what charackter are qou spliting on as well as the text in string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM