当 MultiColumn 设置为 true 时,如何使选中列表框可垂直滚动?

发布于 2024-07-13 06:13:01 字数 633 浏览 7 评论 0 原文

我有一个 Checkedlistbox,它有 3 行高,并且足够大以显示大约 5 个元素。

只要我的元素少于 15 个,一切都会运行良好。 但是,如果我添加第 16 个元素,checkedlistbox 将显示一个水平滚动条,该滚动条占用 2 个项目行,这意味着所有项目现在仅位于一行上。

更糟糕的是,如果我删除多余的项目,水平滚动条将保持在原位。

我尝试过使用 :

mycheckedlistbox.HorizontalScrollbar = false;
mycheckedlistbox.ScrollAlwaysVisible = false;

但这似乎没有任何效果。

我使用 multicolumn=true 模式,这似乎会导致这种不当行为

有没有办法阻止控件显示水平滚动条,并使用垂直滚动条?

我在 msdn 论坛,但似乎他没有得到答案。

I've got a Checkedlistbox, which is 3 rows high, and large enough to display about 5 elements.

As long as I've got less than 15 elements, everything runs fine.
However, if I add a sixteenth element, the checkedlistbox displays an horizontal scrollbar which takes 2 item rows, which means all the Items are now on only one row.

Worse, if I remove the extra item, the horizontal scrollbar stays in place.

I've tried using :

mycheckedlistbox.HorizontalScrollbar = false;
mycheckedlistbox.ScrollAlwaysVisible = false;

but this doesn't seem to have any effect.

I use the multicolumn=true mode, which seems to cause this misbehaviour

Is there a way to prevent the control from displaying an horizontal scrollbar, and use a vertical scrollbar instead?

I've found someone with a similar question on msdn forums, but it seems he didn't get an anwser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

椒妓 2024-07-20 06:13:01

好吧,从那里的答案以及我进行的几次测试来看,这似乎有点不可能,但与此同时,我认为你试图违背这个目的。 如果我处于你的位置,我会使用没有网格线且不可编辑的 DataGridView。 您可以更好地控制网格中发生的情况,并且可以比 CheckedListBox 更多地自定义它。 您也可以获得与 DataGridViewCheckBoxColumns 相同的效果。

(如果您需要代码示例,请在评论中发布,我将快速制作一个示例。)

Well, judging from the answers there, and from the few test I ran, this does seem sort of impossible, but at the same time, I think you're trying to defeat the purpose. If I were in you're shoes, I'd use a DataGridView with no grid lines and one that can't be editable. You have much more control over what's going on in the grid, and you can customize it MUCH more than a CheckedListBox. You can have the same effect as you can have DataGridViewCheckBoxColumns there as well.

(If you need a code sample, post in the comments, and I'll whip up a quick sample.)

镜花水月 2024-07-20 06:13:01

滚动条使项目的布局变得双稳态。 您可以通过敲击滚动条的头部来使其消失:

  checkedListBox1.MultiColumn = false;
  checkedListBox1.MultiColumn = true;

这会强制 WF 重新创建控制手柄,闪烁可能几乎不会被注意到。 是的,垂直滚动条是可能的,但您必须放弃多列。

The scrollbar makes the layout of the items bi-stable. You can get the scrollbar to disappear by whacking it on the head:

  checkedListBox1.MultiColumn = false;
  checkedListBox1.MultiColumn = true;

That forces WF to recreate the control handle, the flicker might be barely noticeable. Yes, a vertical scrollbar is possible but you'll have to give up on MultiColumn.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文