开发者

DataGridView and checkboxes re-selecting automatically

开发者 https://www.devze.com 2023-01-01 02:32 出处:网络
I have a strange problem with a DataGridView I\'m using which is bound to a table in开发者_StackOverflow VB.net

I have a strange problem with a DataGridView I'm using which is bound to a table in开发者_StackOverflow VB.net

I've added a checkbox column to allow a user to tick a bunch of rows that I can then loop through and save off to a different table. All the checkboxes are enabled by default. So it's really a case of unchecking the rows which aren't required.

However, the DataGridView re-enables any checkbox that I click after I click on a checkbox in another row. So in effect, only one row can be unchecked at a time.

I'm sure I'm probably missing something obvious here?

EDIT: I forgot to mention this is a Windows form, not an ASP.net application.


I think this is what is happening. Please check if you have checked IsPostback while binding the datagridview. I think the click event of the checkbox is initiating a postback and it is rebinding itself.

HTH


I think the grid is refreshing and then redrawing the default values...


I got it working in the end, although I'm not sure exactly how. It must have been some property that I tweaked in the grid

0

精彩评论

暂无评论...
验证码 换一张
取 消