title: How To Save DataGridView Cell Style to database
body: <p>I am working with a DataGridView in vb.net and I am trying to work on saving changes that are made in the DataGridView to my Access Database. The problem is, The user can change Individual cell background colors by selecting whatever cells they want and then changing the color. I can't figure out how I can save the individual cell background color so that when the program is run again, the colors show up. When the user clicks on save the color format gets erased. I also don't think I can do this on the Access side of it by adding a color column because there will be multiple colors used in each row and column. Is there a way to save cell style formatting? Here is code...
  This is the save button</p>
  
  <pre><code> Private Sub DsfToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles DsfToolStripMenuItem.Click
      BaggersTableAdapter.Update(RentalsDataSet.Tables(0))
      RentalsDataSet.Tables(0).AcceptChanges()
  
  
  End Sub
  </code></pre>
  
  <p>And The button that is clicked to change the color of the selected cells.</p>
  
  <pre><code>  Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
      For i As Integer = 0 To DataGridView1.SelectedCells.Count - 1
          'Dim a As String = (DataGridView1.SelectedCells(i).RowIndex.ToString)
          Dim colIndex As Integer = DataGridView1.SelectedCells(i).ColumnIndex
          Dim rowIndex As Integer = DataGridView1.SelectedCells(i).RowIndex
          DataGridView1.Item(colIndex, rowIndex).Style.BackColor = Color.LightGreen
  
  
      Next
  End Sub
  </code></pre>