Hi,
I have a Checkbox column in the DataGridView.
I am unable to change the state of the checkbox.
Why is this??? What do I need to set in Properties?
Using Visual Studio 2005
Thanks.
| SitePoint Sponsor |



Hi,
I have a Checkbox column in the DataGridView.
I am unable to change the state of the checkbox.
Why is this??? What do I need to set in Properties?
Using Visual Studio 2005
Thanks.





You are probably databinding unconditonally on every Page_Load. If so, guard the databinding with an If (!IsPostBack) { ... }



I am building a Windows Application - not a webpage.
Can I still use Postback??
How should I set the databinding?
Thanks.



OK I am able to Check/Uncheck an unbound DGV CheckBox. Set Read-Only to false.
I want to bind the primary key of my table to the checkbox.
If I do this then I am unable to check/uncheck the checkbox.
Any ideas?
Thanks



This code works for me provided the user only checks the checkbox once...
How Do I ensure the ArrayList only adds when the checkbox is at checked state??
Thanks!!
Code:private void counterPartyDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView dgv2 = sender as DataGridView; if ((e.RowIndex != -1) && (e.ColumnIndex != -1)) { ArrayList mySelectionArray = new ArrayList(); if (e.ColumnIndex == 0) { DataRow dr2 = ((DataRowView)dgv2.Rows[e.RowIndex].DataBoundItem).Row; int mySelection2 = (int)dr2[dgv2.Columns[1].DataPropertyName]; // 1 = unique id column mySelectionArray.Add(mySelection2); } } }
Bookmarks