C1Multiselect - get ID values

Posted by: hrvoje.zirdum on 10 July 2018, 2:40 am EST

    • Post Options:
    • Link

    Posted 10 July 2018, 2:40 am EST

    I have datatable with 3 columns (ID, Name, Description) bound to C1Multiselect. How to get IDs of all selected values in C1Multiselect control. Combobox have DataMember and you can cast data as DataRow. How to accomplish the same in C1Multiselect control?

    Thank You.

    Regards

  • Posted 11 July 2018, 7:27 am EST

    Hello,

    You can fetch the IDs of all the selected items in C1MultiSelect by using the C1CheckListSelectedItemCollection class. Also, the DataRow corresponding to the same can be obtained using the Select method corresponding to the DataTable and using the fetched ID as the FilterExpression.

    Please refer the attached sample for the implementation of the same.

    Let us know if you need further assistance.

    Thanks,

    Esha

    prj_MultiSelect_FetchSelection.zip

  • Posted 8 August 2018, 4:42 am EST

    Hello,

    That doesn’t do what I expected. In your example, in combobox I want to see Names (DisplayMembetPath = Name) and after I select multiple choices in combobox, I want to extract each data member (ID) from selected Names. I can’t do that now.

    I need this for simple scenario:

    User have to see Names in combobox, and when he selects all that he wants and then for example click button Go, I want to collect all the IDs from selected rows and send to database to fetch some data from database based on the IDs.

    Thank You.

    Regards

  • Posted 9 August 2018, 7:20 am EST

    Hello,

    Currently, it is not possible through C1Multiselect. However, I have escalated the enhancement request to our developer team and will revert you once I get any information from them.

    Thanks,

  • Posted 10 August 2018, 2:04 am EST

    Thank You. :slight_smile:

    Hope this can be done fast.

  • Posted 2 October 2018, 1:44 pm EST

    Is this still not possible?

  • Posted 2 October 2018, 2:01 pm EST - Updated 4 October 2022, 2:07 am EST

    It’s definitely available via the Watch window. So it should be possible to get this via reflection.

  • Posted 4 October 2018, 8:28 am EST

    Hello,

    This issue is still with our development team. Could you please share the criticality of this issue for you so that I can raise the priority for you.

    Thanks,

  • Posted 5 October 2018, 7:47 am EST

    Hi All,

    In the meantime, you can use below workaround for getting selected record’s ids:

    List<int> selectedIds = new List<int>();       
            private void button1_Click(object sender, EventArgs e)
            {
                selectedIds.Clear();
                C1.Win.Input.C1CheckListSelectedItemCollection col = c1MultiSelect1.SelectedItems;
                for(int selectCnt=0; selectCnt < col.Count; selectCnt++)
                {
                    for (int itemCnt = 0; itemCnt < c1MultiSelect1.Items.Count; itemCnt++)
                    {
                        if (c1MultiSelect1.Items[itemCnt].GetHashCode() == c1MultiSelect1.SelectedItems[selectCnt].GetHashCode())
                        {
                            selectedIds.Add(Convert.ToInt32(dt.Rows[itemCnt]["Id"]));
                        }
                    }
                }
    
                if (selectedIds.Count>0)
                {
                    selectedIds.Sort();
                    MessageBox.Show("Your selected ids: [" + string.Join(",",selectedIds) + "]");
                }
                else
                {
                    MessageBox.Show("You are not select any option.");
                }
            }
    

    Also find the sample application attached for complete implementation.

    Thanks,

    Singh

    prj_MultiSelect_FetchSelection.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels