【问题标题】:Get string of item from checkboxlist从复选框列表中获取项目字符串
【发布时间】:2013-03-09 15:09:40
【问题描述】:

我想做这样的事情。

String s = "";
foreach (var item in checkedListBox1.Items)
{
        s = checkedListBox1.Items(item).tostring;
         // do something with the string
}

我想要列表框中项目的string

我怎样才能让它运行起来?

【问题讨论】:

    标签: c# winforms checkboxlist


    【解决方案1】:

    我还没有尝试过,但我认为这应该可以。

    string s = "";
    foreach (var item in checkedListBox1.Items)
    {
            s = item.ToString();
             // do something with the string
    }
    

    【讨论】:

    • 我只是在测试中忘记了 () ... 抱歉
    【解决方案2】:
    string  s = "";
    foreach (string item in checkedListBox1.Items)
    {
       s = item;
       // do something with the string
    
    }
    

    【讨论】:

      【解决方案3】:

      我相信您正在寻找的是:

      foreach (var item in checkedListBox1.Items)
      {
          checkedListBox1.GetItemText(item);
      }
      

      可能不是最有用的,但here is the MSDN 对它有用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-02-06
        • 1970-01-01
        • 2015-10-20
        • 1970-01-01
        • 1970-01-01
        • 2019-06-03
        • 2017-06-09
        相关资源
        最近更新 更多