简体   繁体   English

在选中的项目上禁用CheckedListBox自动滚动?

[英]Disable CheckedListBox Autoscroll on item checked?

Situation: I have a CheckedListBox with a horizontal scroll bar enabled with CheckOnClick set to true. 情况:我有一个CheckedListBox,其中的水平滚动条已启用,且CheckOnClick设置为true。 The size of the CheckListBox is such that two column of items is shown. CheckListBox的大小可以显示两列项目。

Issue: When the user clicks on an item in the second column to check it on or off, the horizontal scroll bar automatically shifts the entire row such that it's in the first column. 问题:当用户单击第二列中的项目以将其选中或关闭时,水平滚动条会自动移动整行,使其位于第一列中。

Question: How do I disable the CheckedListBox from automatically shifting? 问题:如何禁用CheckedListBox自动移位? I took a look at the properties but I can't seem to find one that would disable it, does the answer lie in inheriting the CheckedListBox and overriding methods? 我看了一下属性,但似乎找不到能禁用它的属性,答案就在于继承CheckedListBox和重写方法吗?

Thanks for the help! 谢谢您的帮助!

if you always want to go back to the top-left item (scroll back all the way to the left), just select item[0] programmatically on SelectedIndexChanged... this will still fire off the "check" and actually DO the "check on check off", but will return to the first item in the list... 如果您始终想返回左上角的项目(一直向左滚动),只需以编程方式在SelectedIndexChanged上选择item [0] ...仍会触发“检查”,而实际上会执行“选中””,但将返回到列表中的第一项...

like this: 像这样:

private void lst_Servers_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.lst_Servers.SelectedIndex = 0;
    }

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

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