How to pass a parameter to DataPrpetyName (in DataGrid) C #

0

How can I pass a parameter there? For example changing the id_inss to id_example?

I found no way to do it.

    
asked by anonymous 16.08.2018 / 14:52

1 answer

2

When you add a column to DataGridView , you create a DataGridViewColumn object, which in your code is called codigo (there in the Name property). Then you can change any value of the object.

Example:

string p = "id_exemplo";
codigo.DataPropertyName = p;

is also equivalent to:

string p = "id_exemplo";
dataGridView1.Columns[codigo.Name].DataPropertyName = p;
  

I recommend reviewing the names of variables and properties.

    
16.08.2018 / 15:42