Change and Save Color from Datagridview Line

Asked

Viewed 151 times

2

I want to change the color of the line DataGridView and even with you.

Code:

private void btnativo_Click(object sender, EventArgs e)
{
    MudarCor();
}

public void MudarCor()
{
    dgvIngrediente.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    dgvIngrediente.CurrentRow.DefaultCellStyle.BackColor = Color.Yellow;
}
}
}

But when I close my form and open it again, the lines of DataGridView return with the normal color and not with the one I changed. I would like to know how I do to save the color and leave it permanent.

  • 1

    you have to record this change colors in the database I see no other way!

  • I thought there was another way.

  • permanent in my view would be database, that every time would have a color already chosen by you, opened the form read the database and ready color chosen shows... I see no other way...

  • If Voce already has a database for the system, it is better to use even the database, otherwise Voce can use an xml file or another text file. These would be much simpler than creating a database just to record a configuration.

  • Enzo, have you tried using Attributes and giving a class to Datagridview? So the class will remain in it anyway, unless it refreshes the page.

No answers

Browser other questions tagged

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