|
-
Sep 19th, 2011, 10:51 AM
#1
Thread Starter
Member
Getting values from DataGridView
Hi,
I have a DataGridView on a WinForm that has a column with a combo box in it.
The combo is populated from a datasource and all works great.
My problem is this:
How do I get the value selected (or the text) in the combobox for a specific row when a button is pressed?
any help will be gratefully recieved
thanks
-
Sep 19th, 2011, 11:18 AM
#2
Member
Re: Getting values from DataGridView
I couldn't understand a bit of your question but it looks like you want to get those values from a selected row.
adgda Code:
Textbox1.Text = DataGridView1.SelectedCells(0).Value
0 represents the column.
-
Sep 19th, 2011, 01:13 PM
#3
Hyperactive Member
Re: Getting values from DataGridView
Code:
'Get the index value of the current combo selection in grid
Dim myComboBoxCell As DataGridViewComboBoxCell = DirectCast(dgv.Item(column, row), DataGridViewComboBoxCell)
Dim SelectedIndex As Integer = myComboBoxCell.Items.IndexOf(myComboBoxCell.Value)
'Get text value of combobox
Dim myComboBoxCell As DataGridViewComboBoxCell = DirectCast(dgv.Item(column, row), DataGridViewComboBoxCell)
Dim TypeValue As String = MyComboBoxCell.Value
-
Sep 20th, 2011, 04:15 AM
#4
Thread Starter
Member
Re: Getting values from DataGridView
That is exactly what i needed.
Thank you so much.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|