Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Sometimes, selecting a data grid cell doesn't set the cell's Selected property to true?

$
0
0

I am working with a data grid. When I select a given cell, I want to keep track of the index of the row that cell is on, using the following code:

selectedRows.Clear();
for (int i = 0; i < dataGrid.RowCount; i++)
{
                if (dataGrid[column, i].Selected)
                {                    
                    selectedRows.Add(i);
                }
}

This works 80% of the time. However, occasionally, when I select the name cell of a row, it highlights the cell blue, which leads me to believe I selected it, but the index is not added to <g class="gr_ gr_32 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="32" id="32">selectedRows</g>. Is there something I am missing here?

I have checked that the "column" variable is correct. 




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>