Solved

checkbox checked on selected index changed in combobox in a datagridview

Posted on 2009-03-31
12
337 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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