Click here to Skip to main content
15,907,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am working on vb.net.... i have a datagridview (Customers) which contains the customer details such as phone number, address, company etc?? i want to get the values of the selected row into the textboxes and comboboxes respectively.... i have been able to get values into the textboxes but not into the comboboxes..... !!!

Pleaseee Help sooon..!!!!

Thanks In advance :) :)
Posted

VB
textobx.text=Datagridview1.selectedItem.cells(0).text

Here '0' represents the column of the selected record.
 
Share this answer
 
v2
Comments
Cluelesssssss 10-Jan-12 10:13am    
Hi, thanks for the reply. this is for the textbox right?? could u give me codes for getting values into the combobox??

Thanks :)
VB
dim Value as string = Datagridview1.selectedItem.cells(0).text
Combobox1.items.add(Value)


Have a read of this for more information
How to: Add and Remove Items from a Windows Forms ComboBox, ListBox, or CheckedListBox Control[^]
 
Share this answer
 
Comments
Cluelesssssss 10-Jan-12 12:12pm    
hi....Thanks alot for the reply. In my case i have to load details of the selected row of the datagridview into the combobox. the details in the datagridview have been saved earlier to the database.!! i am using sql server 2008 as the backend
Simon_Whale 10-Jan-12 12:15pm    
it depends on what sort of information is to be stored in the combobox what information you want to get out of the combobox etc on what advice I could give
Cluelesssssss 10-Jan-12 12:17pm    
in my datagridview i have a column called Company, so the name of the company of teh selected row has to be shown in the combobox.!!
Simon_Whale 10-Jan-12 12:22pm    
dim Value as string = Datagridview1.CurrentRow.Cells(CoMpanyColumnNumber).Value
Combobox1.items.add(value)

Just change the values of Combobox1 and datagridview1 for the names of the controls on your form
Cluelesssssss 11-Jan-12 0:29am    
i tried your codes. Its not working :(

any other way to do this??? please help!!! :(
VB
i = datagridview1.CurrentRow.Index

 Combobox1.Text = datagridview1.Item(3,i).Value
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900