DataGridView Selection is cleared

0
0

Hi team,

Anyone has come accross a scenario where the DataGridView Selection works only once until i reload/restart the application. When I select a Row for the First time, I am able to get SelectedRows.Count as 1, but when I move to Select another Row, the Count becomes 0(zero). Is there a property am missing ?

  • Sam Baraka
    I resolved this by implementing a CellClick even to Select the Row when a cell is clicked. What was happening is that Selection worked only on the initial Row that is Selected when the form is loaded. If you select another row, it doesnt select. But initial row selected, works ok. Resolved for now with CellClick event to select the row.
  • Frank (ITG)
    Hi Sam, even though it seems you resolved it with a CellClick, the overall scenario is unclear to me. If it continues or reappears to be a problem, feel free to reach out again, ideally with a test case that illustrates that issues. Best regards, Frank
  • Sam Baraka
    Hello I have been trying to reproduce this error on a new Application which I wanted to share, but i am not able to reproduce it in a new App. Its only happening on my application which is abit big to share. However, this is my code below: string clientID = “”; if (dataGridView1.SelectedRows.Count > 0) { AlertBox.Show(“Row Selected”); clientID = (string)dataGridView1.SelectedRows[0].Cells[1].Value; } What I have noted is when I remove this line clientID = (string)dataGridView1.SelectedRows[0].Cells[1].Value;, it works fine. Meaning I can select a row, click a button to get the alert, move on to select another row and it shows the alert. If i try to get selected value, it only works first time, I hope it makes sense. Thanks
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.