Results 1 to 4 of 4

Thread: Getting values from DataGridView

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2009
    Posts
    39

    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

  2. #2
    Member srspiewarmer's Avatar
    Join Date
    Oct 2010
    Location
    Manila, Philippines.
    Posts
    58

    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:
    1. Textbox1.Text = DataGridView1.SelectedCells(0).Value

    0 represents the column.

  3. #3
    Hyperactive Member
    Join Date
    Jun 2009
    Posts
    307

    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

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2009
    Posts
    39

    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
  •  



Click Here to Expand Forum to Full Width