How to display the selected data in a Datagridview in Windows Form c #?

0

I have this Datagridview

at the moment of clicking on send I want the items I select with the checkbox to appear on a messagebox and show me (code), (full name)

I'm trying with this method

 string text = string.Empty;
                foreach (DataGridViewRow row in dataGridViewSMS.Rows)
                {
                    if (Convert.ToBoolean(row.Cells["Estado"].Value))
                    {
                        text += $@"{row.Cells["Codigo"].Value} - {row.Cells["NombreCompleto"].Value} 
                {Environment.NewLine}";
                    }
                }
                MessageBox.Show(text);

throws me this error

    
asked by Rodrigo Rodriguez 16.10.2017 в 18:41
source

1 answer

0

e there my solution, I hope it serves you.


 string text = string.Empty;
                foreach (DataGridViewRow row in dataGridViewSMS.Rows)
                {
                    if (Convert.IsDBNull(row.Cells["Estado"].Value) ? false : (bool)row.Cells["Estado"].Value)
                    {
                    text += $@"{row.Cells["codigo"].Value} - {row.Cells["NombreCompleto"].Value} {Environment.NewLine}";
                    }
                }
                MessageBox.Show(text);

    
answered by 16.10.2017 / 20:22
source