Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,
My problem is i have added check box column,n in data grid view using c#.
but check box can't work Like, its not clicking so how can i add check box that its work properly in particular column and row of data grid view.
Here is my code of C#:-
DataGridViewCheckBoxColumn CheckboxColumn = new DataGridViewCheckBoxColumn();
CheckBox chk = new CheckBox();
CheckboxColumn.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns.Add(CheckboxColumn);
CheckboxColumn.DisplayIndex = 1;
CheckboxColumn.HeaderText = "Select";

how can i add in particular row and columns?

What I have tried:

how can i add check box in particular rows and columns in data grid view using c#?
Posted
Updated 22-Jun-16 18:57pm
Comments
Herman<T>.Instance 16-Jun-16 5:07am    
is the column or field read only? Is AutoPostback set inclusive the command?
Sinisa Hajnal 16-Jun-16 9:15am    
If the grid in not focused, first click focuses the cell, only second goes through. Also, field may not be read only and has to be wide enough to show the checkbox.

1 solution

with default datagridview using this code, it works:
C#
var column = new DataGridViewCheckBoxColumn();
column.HeaderText = "Abc";
column.Name = "Abc";
dataGridView1.Columns.Insert(0, column);


Otherwise, probably you have another formatting for your datagridview...
 
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