473,327 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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

173 100+
Morning,

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

googling but no joy

ta
Mar 29 '12 #1
1 9132
Gopi
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
  10.  
  11.  
  12.  
'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

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

Similar topics

2
by: Greg | last post by:
I've populated all the cells in a combo box column with values from 1 - 50 using the following code: foreach (DataGridViewRow row in uxTabSummary.Rows) { DataGridViewComboBoxCell cell =...
3
by: sklett | last post by:
I'm changing from a DataGrid to a DataGridView and have run across a problem. The items that are bound to the DataGrid have an int Property that represents a primary key of a lookup table in my...
1
by: Terry Olsen | last post by:
I have a Datagridview that is bound to a DataTable. So there are no column templates to modify at design time. Is there a way I can convert a certain column (if it exists) to a ComboBoxColumn at...
1
by: Bhavanimikkilineni | last post by:
H, At this moment my problem is how to make suplier combobox has different list in every row. I want suplier lists that related with a certain product instead of providing all the supliers. Let say...
1
by: Joel1334 | last post by:
Hi! How can I change forecolor of a selected value in combobox? when I select a value in a combobox and press a button to "activate" what I've selected I want the text to be green and then...
3
by: Motawee | last post by:
i am making a windows form application that contains a datagridview that is filled with employees names the program is for the attendance absence holidays of employees in the company so i...
0
by: Chris Bray | last post by:
I have a data grid view which works very well in almost all respects. However, I have a problem that arises when I allow the addition of items to the grid on the fly. I do this by intercepting the...
0
by: priyamtheone | last post by:
There's an editable datagridview populated from a table say tblItems. Among the columns of the datagridview there's a combobox column named 'Category'. This column is populated by the respective...
3
by: Rania Hassan | last post by:
I created JSP page containing a form with two comboboxes, how can I get the selected value from the first combobox to pass it to SQL statement used by the second combobox? here is my code with...
0
by: visweswaran2830 | last post by:
Hi, I am having datagridview in that I have datagridview combobox column and noraml textfield. I want to know that how can I load selected value in that combox box when I am loading all entered...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.