【问题标题】:Get Checked active value in a CheckedComboBoxEdit [closed]在 CheckedComboBoxEdit 中获取 Checked 活动值 [关闭]
【发布时间】:2016-08-10 11:15:43
【问题描述】:

我想知道如何在 CheckedComboBoxEdit 中进行检查以将活动值保存在数据库中。 我有一个包含 N 数据量的列表,我只想保存活动数据。

谢谢!!

【问题讨论】:

    标签: c# devexpress


    【解决方案1】:

    您可以使用 CheckedComboBoxEdit.Properties.GetItems.GetCheckedValues() 方法。它只是返回检查项目的值 底层列表控件。

    要完成此任务,您还可以使用以下方法:

        string items = string.Empty;
        foreach (CheckedListBoxItem item in checkedComboBoxEdit1.Properties.GetItems())
            if (item.CheckState == CheckState.Checked)
                items += string.Format("{0} YES \r\n", item.Description);
            else
                items += string.Format("{0} NO \r\n", item.Description);
        items = items.TrimEnd("\r\n".ToCharArray());
        XtraMessageBox.Show(items);
    

    更多参考资料:

    Get Checked Items In A DevExpress CheckedComboBoxEdit
    How to iterate through through CheckedComboBoxEdit
    How to retrieve the checked items in the CheckedComboBoxEdit control

    【讨论】:

    • 谢谢尼兰詹!我正在尝试使用 CheckedCombo,但这向我显示了一个无效值错误。显然,我不能放置两个选中的选项。
    • 显示一些您遇到错误的代码。 .他们可能很容易理解确切的问题。
    • 这是我的代码private void btnGuardar_Click(object sender, EventArgs e) { EntidadRentas reg = new EntidadRentas(); for (int i = 0; i < checkedComboBoxEdit1.Properties.Items.Count; i++) { CheckedListBoxItem item = checkedComboBoxEdit1.Properties.Items[i]; if (item.CheckState == CheckState.Checked) { Renta.PeliculaId = (int)item.Value; ShowWaitDialog(); try {...
    • 对不起,这是我第一次使用它。好吧,关键是,当我想选择两个检查时,控件将“X”放在红色圆圈中,并且消息显示“无效值”。我想按我的列表保存每条记录。
    • 通过引用的链接.. 附上的示例项目很少。尝试运行它们并观察此控件的行为。希望这些可以帮助您解决问题。
    【解决方案2】:

    你好,你可以试试这个

    CheckedComboBoxEdit.Properties.GetItems.GetCheckedValues()
    

    如果它适合你,请告诉我。

    有关 CheckedComboBoxEdit 成员的更多信息: https://documentation.devexpress.com/#WindowsForms/DevExpressXtraEditorsCheckedComboBoxEditMembersTopicAll

    【讨论】:

    • 它正在工作!谢谢! :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-01
    • 1970-01-01
    相关资源
    最近更新 更多