How to pass a parameter to Dataprpetyname (in Datagrid) C#

Asked

Viewed 47 times

0

inserir a descrição da imagem aqui

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

I couldn’t find a way.

  • pass parameter or rename property ? on this screen, just change... you want via code ? if yes, you have to change the property of Datagridviewcolumn, since you are handling a...

  • So I want to "put" the value of a variable to change the property, and depending on that "value" change the property

1 answer

2


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

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.

  • 1

    That’s right, thank you!!!

  • Thank you !!!!!!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.