Selection changed textbox value C#

  • 169 Views
  • Last Post 27 March 2019
  • Topic Is Solved
Stylus STYLUS posted this 24 March 2019

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  

private void testDataGridView_SelectionChanged(object sender, EventArgs e)  
       {  

           if (testDataGridView.SelectedRows.Count > 0)   
           {  

           string test = testDataGridView.SelectedRows[0].Cells["columnname"].Value.ToString();  

testTextBox.Text = test;  

            }  
        }  
lucy posted this 27 March 2019

I think you should add a bindingsource to datagridview, then binding data to the textbox.

Each time you focus row on your datagridview, your data will show in textbox control.

  • Liked by
  • Stylus STYLUS
Close