CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2008
    Posts
    43

    DataGridViewComboBoxCell selected index

    I have a datagridview that the user can add and delete rows from. one of the columns is a DataGridViewComboBoxColumn. i want to be able to loop through each row in the grid and get the selected index of the combo box for that row. i've tried everything i can think off but can't get it to work. could anyone help me?

    something like this:

    Code:
    for (int i = 0; i < DataGridView.Rows.Count; i++)
    {
        MessageBox.Show(DataGridView.Rows[i].Cells["ComboBoxColumn"].SelectedIndex.ToString();
    }
    but obviously this doesn't work because it returns the value of the cell rather than the actual combo box

  2. #2
    Join Date
    Jan 2009
    Posts
    6

    Re: DataGridViewComboBoxCell selected index

    I assumed that you bind the ComboBox column to the data source. If yes, ValueMember property of the column should return value of the selected item in the combobox.

    www.madartsoft.com C# controls, Help Desk Software

  3. #3
    Join Date
    Dec 2006
    Posts
    38

    Re: DataGridViewComboBoxCell selected index


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

Featured