Link to home
Start Free TrialLog in
Avatar of yuvaratna
yuvaratna

asked on

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
Avatar of yuvaratna
yuvaratna

ASKER

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....
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent..Thanks a lot ..YOu solved three of my Problems today!
Glad I could help :)
jpaulino
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....
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....

Not sure ... you have

nameA      Y
nameB      Y
nameC     N
and you're usign valuemember and displaymember to store it ?
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" ..
Running fine now, right ?
let me put the problem more clearly....
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...
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