By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,064 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,064 IT Pros & Developers. It's quick & easy.

How do i get the selected value of a datagridview combobox column?

P: 173

i would like to know how i get the selected value of a datagridview combobox column?

googling but no joy

Mar 29 '12 #1
Share this Question
Share on Google+
1 Reply

P: 5
hi man
do you want to know about selected row value from paricular column in datagridview and store that values into ur combobox ?
Or get combobox values and load into datagridview in particular column? Can you send ur code or send ur problem clearly?
anyway here is answer for first question
'Here put ur DBconnection
'I use con, cmd,dr, dt as object of sqlconnection,command,
'sqldatadapter,datatable you can as you declared object
'example: design form with Two text boxes, one combobox in combobox you 'can store the Course of the student
Expand|Select|Wrap|Line Numbers
  1.  In Grid Selection Changed Event you write this code
  2. dr = New SqlDataAdapter("Select * from student where Studentid = " &
  3. givenid & " ", con)
  4. dr.Fill(dt)
  5. If dt.Rows.Count > 0 Then
  6.                 txtStudentid.Text = dt.Rows.Item(0).Item("Studentid")
  7.                 txtFname.Text = dt.Rows.Item(0).Item("Fname")
  8.                 ComboBox1.SelectedItem = dt.Rows.Item(0).Item("Course")
  9. End if
'While you run the formload event you load combox values also
'by same way use above code to select course from student table and 'assign it to combobox.
'Then it run smartly
Mar 30 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.