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(By Val sender As Object, ByVal e As EventArgs)
Select Case DataGridView1.CurrentCell. ColumnInde x
Case 2
Dim cell As DataGridViewComboBoxEditin gControl = DirectCast(sender, DataGridViewComboBoxEditin gControl)
If cell.ValueMember = "abc" Then
ColReportReqd.Selected = True
ColReportReqd.ReadOnly = True
end sub
i tried this
Public Sub cb_SelectedIndexChanged(By
Select Case DataGridView1.CurrentCell.
Case 2
Dim cell As DataGridViewComboBoxEditin
If cell.ValueMember = "abc" Then
ColReportReqd.Selected = True
ColReportReqd.ReadOnly = True
end sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent..Thanks a lot ..YOu solved three of my Problems today!
Glad I could help :)
jpaulino
jpaulino
ASKER
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....
so what is the property that is used to get the value of the selected item....
ASKER
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....
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 ?
ASKER
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" ..
Now everything is working fine...but i checked it for a particular iitem...with display member "abc" ..
Running fine now, right ?
ASKER
let me put the problem more clearly....
ASKER
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...
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
... or I'm not getting the point
ASKER
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....