views:

923

answers:

3

What is the easiest way to create a DataGridView column that contains a CheckedListBox control for each cell? The CheckedListBox does not need to be databound.

A: 

I don't know about the easiest, but you would probably want to create a custom object that inherits from DataGridViewCell, and also create a control containing your CheckedListBox. Then override the Paint method inside of your custom object and have it draw in the control containing the CheckedListBox.

Once all of that is done, create a DataGridViewColumn, and set the CellTemplate property to the custom DataGridViewCell object you've created.

Zensar
A: 

Add a Template Column and then Edit templet column from start tag. Drag and drop a checkbox into it. you can remove the lable and text box that is created when a databount is modified to Template.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
            <Columns>                
                <asp:TemplateField>                   
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>                
            </Columns>
        </asp:GridView>
How about for winforms?
JC
A: 

For winforms, in the past I think I used to do it this way:

Either, edit columns for the grid view and add a checkbox column or you can go into the designer of the form and put the following:

private System.Windows.Forms.DataGridViewCheckBoxColumn Column1;//Where column1 is the name of the column.
Dustin Scaggs
That's for a checkbox. I'm talking about a checked listbox.
JC
my bad, i must've read it too fast.
Dustin Scaggs