Solved

checkbox checked on selected index changed in combobox in a datagridview

Posted on 2009-03-31
12
345 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:yuvaratna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 

Author Comment

by:yuvaratna
ID: 24033068
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
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24033227
You can do this way:

Me.DataGridView1(Colreportreqd.Index, Me.DataGridView1.CurrentRow.Index).Value = True
0
 

Author Closing Comment

by:yuvaratna
ID: 31565037
Excellent..Thanks a lot ..YOu solved three of my Problems today!
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 48

Expert Comment

by:jpaulino
ID: 24033327
Glad I could help :)
jpaulino
0
 

Author Comment

by:yuvaratna
ID: 24033344
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
 

Author Comment

by:yuvaratna
ID: 24033364
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
 
LVL 48

Expert Comment

by:jpaulino
ID: 24033401

Not sure ... you have

nameA      Y
nameB      Y
nameC     N
and you're usign valuemember and displaymember to store it ?
0
 

Author Comment

by:yuvaratna
ID: 24033434
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
 
LVL 48

Expert Comment

by:jpaulino
ID: 24033517
Running fine now, right ?
0
 

Author Comment

by:yuvaratna
ID: 24033535
let me put the problem more clearly....
0
 

Author Comment

by:yuvaratna
ID: 24033566
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
 
LVL 48

Expert Comment

by:jpaulino
ID: 24033660
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question