Goran Bibic

Goran Bibic

  • 480
  • 2.9k
  • 200.8k

Selection changed textbox value C#

Mar 24 2019 10:47 AM
If datagrid no have rows in my textbox have values from last selected values...

Need help IF DATAGRID NO HAVE VALUES TEXTBOX EMPTY

Thank you
 
  1. private void testDataGridView_SelectionChanged(object sender, EventArgs e)  
  2.        {  
  3.   
  4.            if (testDataGridView.SelectedRows.Count > 0)   
  5.            {  
  6.   
  7.            string test = testDataGridView.SelectedRows[0].Cells["columnname"].Value.ToString();  
  8.   
  9. testTextBox.Text = test;  
  10.   
  11.             }  
  12.         } 
 

Answers (1)