【问题标题】:how back the the first index after scroling to the last index on listbox滚动到列表框中的最后一个索引后如何返回第一个索引
【发布时间】:2017-05-20 18:25:22
【问题描述】:

我使用此代码移动到下一个索引listBox1.SelectedIndex = listBox1.SelectedIndex +1; 但问题是当我在最后一个索引上并且我单击具有该代码的下一个按钮时崩溃任何建议在单击它后使下一个按钮回到第一个索引??

【问题讨论】:

    标签: c# winforms listbox listboxitem


    【解决方案1】:

    选择下一项的代码:

    if (listBox1.SelectedIndex < listBox1.Items.Count - 1)
    {
        listBox1.SelectedIndex += 1;
    }
    else
    {
        listBox1.SelectedIndex = 0;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-09-14
      • 2016-05-16
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 2017-05-11
      • 1970-01-01
      • 2011-12-14
      • 1970-01-01
      相关资源
      最近更新 更多