Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi
I have combobox that is filled by a linq query
I want to have the choice to do multiple selection in this ComboBox

this is what I have done:
private void cmbECUType_SelectedIndexChanged(object sender, EventArgs e)
{
    string cmbVal = cmbModel.SelectedValue.ToString();
    string Id = cmbVal.Substring(0, 3);
    string Model = cmbVal.Substring(4, cmbVal.Length - 4);
    string fileName = string.Empty;
    string Val = cmbECUType.SelectedValue.ToString();

    LINQSQLDataContext db = new LINQSQLDataContext();
    cmbECUPartNumber.DataSource = (from a in db.InfoProg_wiTECH_Associas
                                   where
                                       a.Model == Model &&
                                       a.ModelID == Id &&
                                       a.Acr == Val
                                   join g in db.InfoProg_wiTECH_Globals
                                    on a.KeyJoined equals g.NomeFile
                                   select (g.a+ " - " + g.b+ " - "
                                          + g.c+ " - " + g.d)
                                          ).Distinct();
    cmbECUPartNumber.Text = "     - Choose... -";
}

now I have my combox filled,but how can I add checkboxes?
Posted
Updated 5-May-15 2:42am
v2

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-May-15 11:34am    
5ed.
—SA
Sascha Lefèvre 5-May-15 11:47am    
Thank you, Sergey.
Sascha Lefèvre 7-May-15 3:18am    
lol :-))) just imagine my previous reply-comment one answer below
CHill60 7-May-15 3:59am    
I did chuckle - at least SA got his thank you ;-p
Sascha Lefèvre 7-May-15 4:24am    
Glad I could entertain you ;-)
The standard ComboBox doesn't offer the functionality of CheckBoxes. You need to either build your own custom control or search for an available solution. Here are two Codeproject-articles presenting solutions for this:

CheckBox ComboBox Extending the ComboBox Class and Its Items[^]
A ComboBox with a CheckedListBox as a Dropdown[^]

If none of these should fit your needs, you should see what else Google can offer you:
https://www.google.com/search?q=c%23+combobox+with+checkboxes&ie=utf-8&oe=utf-8[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-May-15 11:35am    
5ed.
—SA
Maciej Los 7-May-15 2:14am    
5ed!
Sascha Lefèvre 7-May-15 3:19am    
Thank you, Maciej :)
You can use Checkboxlist control a small demo below modify it a/c to ur requirement

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EgApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            checkedListBox1.Items.Add(textBox1.Text);
        }


    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900