在下拉列表中添加复选框 [英] add checkbox in dropdownlist

查看:53
本文介绍了在下拉列表中添加复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用了 Telerik 控件.我想在 drdownlist 中添加复选框并选择多个值并存储在数据库中.我正在使用 c#.net lang.它是基于窗口的应用程序.

I'm using telerik control in my project. I want to add checkbox in drdownlist and select multiple values and store in database. I m using c#.net lang. and it is window base application.

推荐答案

如果您使用的是 Windows 应用程序,那么最好使用RadListBoxItem"而不是下拉列表.它在 Telerik 中易于使用且使用效率更高.

if you are using windows application then its better to use "RadListBoxItem" instead of dropdown list. It is easy to use and more efficiently used in Telerik.

 for (int i = 0; i < 10; ++i)
        {
            RadListBoxItem item = new RadListBoxItem();
            RadCheckBoxElement checkBox = new RadCheckBoxElement();
            checkBox.Text = "Item " + i;
            checkBox.ToggleState = i % 2 == 0 ? Telerik.WinControls.Enumerations.ToggleState.On: Telerik.WinControls.Enumerations.ToggleState.Off;
            //remove this line if you dont want to close popup on checkbox checked
            checkBox.ToggleStateChanged += new StateChangedEventHandler(checkBox_ToggleStateChanged);
            item.Children.Add(checkBox);

            this.radComboBox1.Items.Add(item);
        }

在加载表单或您自己想要的位置编写上述代码.然后写下面的代码

write the above code at load form or at your own desired location. Then write the below code

 void checkBox_ToggleStateChanged(object sender, StateChangedEventArgs args)
    {
        this.radComboBox1.CloseDropDown();
    }

使用的命名空间是using Telerik.WinControls.UI;

这篇关于在下拉列表中添加复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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