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

为什么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.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?