|
hi I Create a Datagrid View in Csharp application in that i will create check box inside the datagrid view. at run time i cant select check boxes . i dont know why this problem occur. Pls any bodyhelp me to solve this error |
| rkhema Monday, August 17, 2009 6:37 AM |
Add CellMouseClick Event: and put this code in:
int
currentRow = int.Parse(e.RowIndex.ToString());
if
(this.Columns[e.ColumnIndex].HeaderText == "Your Column Name" && currentRow >= 0)
{
if (this.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
this.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = !(bool)this.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
else
this.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = true;
}
Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.
- Proposed As Answer by_SuDhiR_ Monday, August 17, 2009 9:27 AM
- Marked As Answer byrkhema Wednesday, August 26, 2009 9:11 AM
-
|
| _SuDhiR_ Monday, August 17, 2009 6:44 AM |
Can you provide more details, 1) is CheckBox Column or datagridviewis ReadOnly ? 2) Is CurrentCellDirtyStateChanged event fired on first click ?
- Marked As Answer byrkhema Wednesday, August 26, 2009 9:11 AM
-
|
| NareshG Monday, August 17, 2009 10:43 AM |
Hi rkhema, Before I can locate the problem, I want to know some detail information about it. Do you use databinding? If you use databinding, does that column a bool column in DataSource table? Also please check whether that column has been set to ReadOnly? Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer byrkhema Wednesday, August 26, 2009 9:11 AM
-
|
| Kira Qian Wednesday, August 19, 2009 2:48 AM |
Add CellMouseClick Event: and put this code in:
int
currentRow = int.Parse(e.RowIndex.ToString());
if
(this.Columns[e.ColumnIndex].HeaderText == "Your Column Name" && currentRow >= 0)
{
if (this.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
this.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = !(bool)this.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
else
this.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = true;
}
Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.
- Proposed As Answer by_SuDhiR_ Monday, August 17, 2009 9:27 AM
- Marked As Answer byrkhema Wednesday, August 26, 2009 9:11 AM
-
|
| _SuDhiR_ Monday, August 17, 2009 6:44 AM |
Can you provide more details, 1) is CheckBox Column or datagridviewis ReadOnly ? 2) Is CurrentCellDirtyStateChanged event fired on first click ?
- Marked As Answer byrkhema Wednesday, August 26, 2009 9:11 AM
-
|
| NareshG Monday, August 17, 2009 10:43 AM |
Hi rkhema, Before I can locate the problem, I want to know some detail information about it. Do you use databinding? If you use databinding, does that column a bool column in DataSource table? Also please check whether that column has been set to ReadOnly? Sincerely, Kira Qian Please mark the replies as answers if they help and unmark if they don't.- Marked As Answer byrkhema Wednesday, August 26, 2009 9:11 AM
-
|
| Kira Qian Wednesday, August 19, 2009 2:48 AM |
Hi thanks for ur reply. code is very useful to correct my error. thanks a lot. |
| rkhema Wednesday, August 26, 2009 9:48 AM |
Hi thakns for ur reply. yes i set readonly as 'true' after that am correcting. |
| rkhema Wednesday, August 26, 2009 9:51 AM |
Thanks for ur reply,
yes i set datagrid view is readonly? after ur reply i did some changes. my grid view check box is selected. thanks for ur reply.
|
| rkhema Wednesday, August 26, 2009 9:52 AM |