c# - datagridview .get cell value without leaving row -


i have datagridview in user enters value . enters , new row gets added , user able enter new value.

enter image description here

as user enters names , more rows keep getting added. when user done entering names , clicks button , need using every name entered in grid view.

 foreach (datagridviewrow row in datagridview1.rows)             {                  if (row.cells[0].value != null)                 {                      string user = row.cells[0].value.tostring();                    // using string user                }            } 

this code using read each row. problem facing v

row.cells[0].value doesn't seem catch last active row.

eg. if user has typed "tim" , forced go next empty row ensure tim gets read above code. if still keeps cursor in tim cell after typing , above code doesn't capture "tim" .

how can solve problem ? prefer without using cellchange event or event. have full row select selection mode.

per link, need call datagridview1.endedit(). note method throw exception if edit can't closed (i.e., data in cell not satisfy input validation criteria).


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -