Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear all Senior Programmer,

hello, could you show me the link or source code to save and retrieve the color in datagridview ?

Does anyone knows how to do that ?

I want to store a color in a DataGridView(DGV) (that has been selected by the ColorDialog). The DGV saves to a flat file (.txt) or into a XML File. When the file is opened and the contents read I want to be able to set the row back color of the same DGV to the color in each row.

Thank you in advance for any help you can provide.


Regards,

Agus Salim
Posted

1 solution

Have a look at this example:
VB
Dim oRow as DataGridViewRow = Nothing

For each oRow in Me.DataGridView1.Rows
    If oRow.Index Mod 2 = 0 Then
        oRow.DefaultCellStyle.Color = Color.Yellow
    Else
        oRow.DefaultCellStyle.Color = Color.Blue
    End if
Next


The rest you need to do by yourself.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900