自动检查复选框列表的最后一项 [英] automatically check the last item of checkboxlist

查看:85
本文介绍了自动检查复选框列表的最后一项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复选框,其中的项是使用数据读取器从数据库中填充的.

当表单包含此复选框列表时,将被加载.我希望默认情况下选中/选中此复选框列表的最后一项.

当我删除该选中的项目时,应该检查连续的上一个项目.

任何提示或代码段将不胜感激.

i have a checkboxlist n its item are populated from database using a datareader.

when the form contains this checkboxlist is loaded. i want the last item of this checkboxlist to be checked/selected by default.

and when i delete that checked item, the consecutive upper item should be checked.

Any hint or code snippet would be appreciated.

thanks in advance.

推荐答案

好,在填充后立即检查.这怎么可能是个问题?为此,请使用System.Windows.Forms.CheckedListBox.SetItemChecked(index, true).对于index,请使用Items.Count.

请参阅 http://msdn.microsoft.com/en-us/library/system .windows.forms.checkedlistbox.aspx [ ^ ], http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.setitemchecked.aspx [
Well, check it right after you populate it. How can this ever be a problem? For this purpose, use System.Windows.Forms.CheckedListBox.SetItemChecked(index, true). For index, use Items.Count.

See http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.aspx[^], http://msdn.microsoft.com/en-us/library/system.windows.forms.checkedlistbox.setitemchecked.aspx[^].

—SA


这篇关于自动检查复选框列表的最后一项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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