checkbox checked on selected index changed in combobox in a datagridview

I have a combobox with like 10 items and a checkbox in a datagridview...if the user selects certain items from the dropdown in a combobox, the chechbox need to be checked by deafualt..and it should be read only...how can i do this....

i tried this
 Public Sub cb_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

Select Case DataGridView1.CurrentCell.ColumnIndex

 Case 2
                Dim cell As DataGridViewComboBoxEditingControl = DirectCast(sender, DataGridViewComboBoxEditingControl)
                If cell.ValueMember = "abc" Then

                    ColReportReqd.Selected = True

                    ColReportReqd.ReadOnly = True

end sub
yuvaratnaAsked:
Who is Participating?
 
Jorge PaulinoIT Pro/DeveloperCommented:
You can do this way:

Me.DataGridView1(Colreportreqd.Index, Me.DataGridView1.CurrentRow.Index).Value = True
0
 
yuvaratnaAuthor Commented:
Colreportreqd is the name of the checkbox

Thsi is working fine but is there any property like checkbox1,checked=true ????

because the selected property is not the correct one to us in this context....
0
 
yuvaratnaAuthor Commented:
Excellent..Thanks a lot ..YOu solved three of my Problems today!
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Jorge PaulinoIT Pro/DeveloperCommented:
Glad I could help :)
jpaulino
0
 
yuvaratnaAuthor Commented:
Just a small question on the line "  If cell.ValueMember = "abc" Then"  istead of "abc", i wanted the checkbox to be checked if the user selectes certain items from the drop down...so for the column "colreportreqd" , i had the display member as column say column a from the database...it has only two values 'Y' and 'N' ...so if the value of the selected item is 'Y' then i wanted the checkbox to be checked....

so what is the property that is used to get the value of the selected item....
0
 
yuvaratnaAuthor Commented:
not the display member ...the value member is bound to a column say column a, which has only two values 'Y' and 'N' ...so if the value of the selected item is 'Y' then i wanted the checkbox to be checked....

so what is the property that is used to get the value of the selected item....
0
 
Jorge PaulinoIT Pro/DeveloperCommented:

Not sure ... you have

nameA      Y
nameB      Y
nameC     N
and you're usign valuemember and displaymember to store it ?
0
 
yuvaratnaAuthor Commented:
yup! thats what i am doing....one column is bound to the display meber and the other column to the value memvber.the value member column has only tow values 'Y' and 'N' ...so what i wanted to do is if the valuemember of the selected display member is 'Y' , i wanted to check the checkbox and make it read only...

Now everything is working fine...but i checked it for a particular iitem...with display member "abc" ..
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Running fine now, right ?
0
 
yuvaratnaAuthor Commented:
let me put the problem more clearly....
0
 
yuvaratnaAuthor Commented:
i have

 ColPurpose.DisplayMember = colpurposedisplaymember
        ColPurpose.ValueMember = colpurposevaluemember

where colpurpose is the combobox, ...the value member just has two values 'Y' and "N' ...what i want is if the valuemember is 'Y', i want checkbox to be checked...
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
You're doing right, you just have to change If cell.ValueMember = "abc" to If cell.ValueMember = "Y"
... or I'm not getting the point
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.