简体   繁体   English

ListBox SelectedItems到MessageBox

[英]ListBox SelectedItems to MessageBox

I have little problem with show string in MessageBox. 我在MessageBox中显示字符串几乎没有问题。 I load date from database into ListBox. 我将日期从数据库加载到ListBox中。

Now I want show selecteditem. 现在我要显示selecteditem。 I have something like this: 我有这样的事情:

StringBuilder message = new StringBuilder();
foreach (var selectedItem in CategorylistBox.SelectedValue.ToString())
{
    message.AppendLine(selectedItem.ToString());
}
MessageBox.Show(message.ToString());

I select "Sci-Fi" movie category, but I get: 我选择“科幻”电影类别,但得到:

http://prnt.sc/dvmfyl http://prnt.sc/dvmfyl

Can someone help me and tell how to display it in one line? 有人可以帮助我,并告诉我如何将其显示为一行吗?

On AddMovieClick please comment every thing else and test this one it will show you current items selected . 在AddMovieClick上,请对其他所有内容进行评论并进行测试,它将显示您当前选择的项目。

if (CategorylistBox.SelectedItems != null)
{
    foreach (var item in CategorylistBox.SelectedItem.ToString())
    {
        Debug.WriteLine("current item "+item);
        // CinemaDataSetTableAdapters.QueriesTableAdapter kTyp = new CinemaDataSetTableAdapters.QueriesTableAdapter();
        // kTyp.AddCategoryType((selectedItem), TitleTextBox.Text);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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