Questions about Checkbox Column in DataGridView  
Author Message
reichard





PostPosted: Visual Basic Express Edition, Questions about Checkbox Column in DataGridView Top

I have two questions regarding a checkbox column in a datagrid view on a form.

1. Another column in the datagridview is a buttoncolumn. When you click on the button in a particular row, it opens another form, inserts data from other columns in the specific datagridview row, and allows the user to input additional information. The checkbox notes whether additional information has been entered or not. Right now, when you click on the button, the form opens whether the checkbox is checked or not. I only want to have the form open if the checkbox is unchecked. How do I check to see if the checkbox is checked before I run the proceedure to open the form The name of the checkbox column is DataGridViewCheckBoxColumn1. I've tried an If Then statement where I check if DataGridViewCheckBoxColumn1.TrueValue = False, but it doesn't work. It may be because it is not referring to the specific row that the button is clicked on.

2. After the user opens the form and enters additional data and clicks on a Save button on the form, how do I then make the checkbox in the datagridview on the other form change from unchecked to checked for the specific record that the user clicked the button to open the form The form with the checkbox remains open in the background while the form with additional information is on top, so the row in the datagridview that the button was clicked should still be "active". How do I change the checkbox from unchecked to checked for that specific row when the user clicks on the Save button

The checkbox in the datagridview has been set to read only so the user cannot change the state of the checkbox, since it references whether additional information has been entered or not. I don't know if this hurts my ability to change the checkbox from unchecked to checked through code.

Any suggestions/code examples would be greatly appreciated. I know my description of my problems might be confusing. I'd be happy to explain something further if you have any questions.

Thanks,

John



Visual Studio Express Editions40  
 
 
reichard





PostPosted: Visual Basic Express Edition, Questions about Checkbox Column in DataGridView Top

Well, I guess you could chalk this up to "give it some time and you will figure it out". After putting some more time into this problem, I have found a solution.

1. For the first problem I had, I used the following code in an If, Then statement:

If CatalogDataGridView.CurrentCell.ColumnIndex = 6 And CatalogDataGridView.Rows(CatalogDataGridView.CurrentCell.RowIndex).Cells(5).Value = False Then

Where ColumnIndex #6 is the button column and Cell #5 is the CheckBox

2. For the second problem I had, I used the following code when the Save button is clicked:

Catalog_Form.CatalogDataGridView.Rows(Catalog_Form.CatalogDataGridView.CurrentCell.RowIndex).Cells(5).Value = True

I guess if anything, posting this question and telling you of my solution might help someone else that is trying to do something similar.

John


 
 
kiwi-b





PostPosted: Visual Basic Express Edition, Questions about Checkbox Column in DataGridView Top

yes!

I needed this just now! thanks for replying to your question!

Brian


 
 
reichard





PostPosted: Visual Basic Express Edition, Questions about Checkbox Column in DataGridView Top

Brian:

Glad to hear my post was helpful.

John