m0_55978028 2021-07-01 15:10 采纳率: 44.4%
浏览 71
已采纳

为什么listbox在删除选中项的时候SelectedIndex会变成-1?

为什么listbox在选中一项的时候SelectedIndex是正确的,但是删除的时候就自己变成了-1?

img

  • 写回答

1条回答 默认 最新

  • Null_Reference 2021-07-01 15:13
    关注

    -1 说明没有选择任何一项

           //
            // 摘要:
            //     Gets or sets the zero-based index of the currently selected item in a System.Windows.Forms.ListBox.
            //
            // 返回结果:
            //     A zero-based index of the currently selected item. A value of negative one (-1)
            //     is returned if no item is selected.
            //
            // 异常:
            //   T:System.ArgumentOutOfRangeException:
            //     The assigned value is less than -1 or greater than or equal to the item count.
            //
            //   T:System.ArgumentException:
            //     The System.Windows.Forms.ListBox.SelectionMode property is set to None.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上