I have a strange problem. Basically I have a datagridview and a button. When I click this button, it checks all the rows for the value of column 1 - the checkbox column. Then it sets the value to true / false depending on what is currently located.
All perfectly.
But then I have one more button to do something with these lines that are checked. I click on it and it only ever identifies the first line as a checkmark. The rest, apparently, are now zero.?
So, how can I programmatically set the value of the checkbox column in the datagrid view and then read it again, make Im seem to exit the label based on my results.
This sets the checkboxes, and I can see them, turn them off manually, etc.
foreach (DataGridViewRow row in dgv.Rows)
{
var ch1 = new DataGridViewCheckBoxCell();
ch1 = (DataGridViewCheckBoxCell)row.Cells[0];
if (ch1.Value == null)
ch1.Value = false;
switch (ch1.Value.ToString())
{
case "True":
ch1.Value = false;
break;
case "False":
ch1.Value = true;
break;
}
}
Then the next button to check the values ββis just a search for zeros
foreach (DataGridViewRow row in rows)
{
var ch1 = new DataGridViewCheckBoxCell();
ch1 = (DataGridViewCheckBoxCell)row.Cells[0];
if (ch1.Value == null)
ch1.Value = false;
switch (ch1.Value.ToString())
{
case "True":
ch1.Value = true;
break;
case "False":
ch1.Value = false;
break;
}
var val = row.Cells["EbayListingID"].Value.ToString();
if (ch1.Value.ToString() == "true") continue;
var listing = dsEntities.EbayListings.First(x => x.EbayListingID.ToString() == val);
SubmitListingForReview(listing, false);
}
source
share