Is it possible to add CheckBoxcolumn only at certain rows in a datagridview?

You need to use the cellpainting event to not display the checkbox at all. I'm not sure if this would have other consquences during data binding but it did not display the checkbox for the rows that I wanted.

You need to use the cellpainting event to not display the checkbox at all. I'm not sure if this would have other consquences during data binding but it did not display the checkbox for the rows that I wanted. I have updated the method for what you would need.

Private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e. RowIndex >= 0 && e. ColumnIndex >= 0) { //if (e.

ColumnIndex == && (e. RowIndex == 1 || e. RowIndex == 2)) if (dataGridView2.Rowse.RowIndex.

Cells"RecordTypeCode".Value.ToString() == "Batch Header" && e. ColumnIndex == ) { e. PaintBackground(e.

ClipBounds, true); e. Handled = true; } } } The condition for e. RowIndex == 1 || e.

RowIndex == 2 is based on the fact that batchheader and entrydetail won't change their position. But if that is dynamic, then you can just check the text in the recordtype column to match BatchHeader and EntryDetail. The if statement is the most important, it checks which particular cell (row, column) is the one you don't want any checkbox in.

They must be used with an AND (&&) as you want one particular cell. You can use the code I have written as is if what you have explained is what you need. You will probably need to add one more check in the if statement for entry detail which needs to be done with an OR (||) with the batch header check.

Exactly how I have in the commented part of the code, taking notice to the brackets especially. I saw the solution at this link which worked when I tried it. There are others mentioned incase this isn't suitable for what you want.

How can I match the text as per you said as my data is dynamic – User Oct 25 '11 at 7:30 You can check whether the text value in a particular cell is equal to the text you want. Datagridview.Rowse.RowIndex. Cells"RecordTypeCode".

Value == "BatchHeader". I think you may have to first cast it to string and it maybe better to use the String. Equals method – nEm Oct 25 '11 at 10:57 Can you check my edits and tell whether it is correct.

But still it is showing check box for every row – User Oct 25 '11 at 11:14 yes that is because your condition is incomplete... see the condition that I have put in my code. Firstly you are missing the check for the checkboxcolumn. Secondly you have the condition only for batch header.

– nEm Oct 25 '11 at 12:00 Can you see my updates and let me know where I went wrong – User Oct 25 '117 at 7:36.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions