如何调整checkedlistbox的大小以查看.net中可见的所有项目? [英] how to resize the checkedlistbox for visible all items in .net?

查看:67
本文介绍了如何调整checkedlistbox的大小以查看.net中可见的所有项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们使用支票列表框显示一些数据,遗憾的是checklistbox没有Autosize属性。所以它只显示4个项目,其他项目在滚动滚动条时可见。如何在dynamicaly中调整其大小。

Hi, friends i uses checked listbox for display some datas, unfortunately checkedlistbox didnt have Autosize property. so it display only 4 items, other items visible onely when scroll the scroll bar. how to adjust its size in dynamicaly.

推荐答案

您可能已经知道,ListBox和CheckedListBox没有为要添加或删除的项目提供事件。



有几种策略可以参加这些活动。您使用哪一个表示您的应用程序工作原理:您是否在代码中添加/删除项目以响应用户在运行时的操作?如果您使用DataSource或BindingList向CheckedListBox提供Items,则可能表示一种技术直接在绑定源上工作。



简单案例,在Windows窗体中,您需要在添加或删除的某些操作后重置代码中的高度项目:
As you may already know, ListBox, and CheckedListBox, provide no Events for Items being added, or deleted.

There are several strategies for getting at those events. Which one you use is indicated by how your application "works:" are you adding/deleting Items in code in response to user actions at run-time ? If you are using a DataSource or BindingList to provide the Items to the CheckedListBox, that may indicate a technique that works directly on the "bound" source.

The simple case, in Windows Forms, where you need to reset the height in code after some operation where you added, or deleted, Items:
checkedListBox1.Height = checkedListBox1.Items.Count * checkedListBox1.ItemHeight;

在Windows窗体中,我将CheckedListBox放在Panel中,Panel的'AutoSize属性设置为'true,CheckedListBox的'IntegralHeight设置为'true;将CheckedListBox的Anchor属性设置为Top,Bottom,Right,Left ...不要使用'Dock属性。



我在WPF中看到了一个例子ListBox ObjectCollection(Items)被强制转换为INotifyCollectionChanged实例[ ^ ],然后访问可用于该集合的非常有用的事件,但在Windows窗体中这是不可能的。

In Windows Forms, I would put the CheckedListBox in a Panel, with the Panel's 'AutoSize property set to 'true, and the CheckedListBox's 'IntegralHeight set to 'true; set the CheckedListBox 'Anchor property to Top,Bottom,Right,Left ... do not use the 'Dock property.

I have seen an example in WPF where a ListBox ObjectCollection (the Items) was cast to an INotifyCollectionChanged instance [^], and then access was available to the very useful Events of that Collection, but in Windows Forms this is not possible.


这篇关于如何调整checkedlistbox的大小以查看.net中可见的所有项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆