Here's a little example. Add Common Dialog control and MsFlexGrid to your form:
By double clicking on any cell in the Grid will let you change it's back color. Then when you close your form, it will save color settings in the registry and use them on next Form_Load event.Code:Private Sub Form_Load() Dim intRow As Integer Dim intCol As Integer With MSFlexGrid1 .Rows = 11 .Cols = 5 For intRow = 1 To .Rows - 1 .Row = intRow For intCol = 0 To .Cols - 1 .Col = intCol .Text = "Field" & intCol & intRow 'get saved settings for the color. 'if settings don't exist, then use default colors .CellBackColor = GetSetting("GridDemo", "Row" & intRow, "Col" & intCol, vbWindowBackground) Next Next End With End Sub Private Sub Form_Unload(Cancel As Integer) Dim intRow As Integer Dim intCol As Integer With MSFlexGrid1 For intRow = 1 To .Rows - 1 .Row = intRow For intCol = 1 To .Cols - 1 .Col = intCol SaveSetting "GridDemo", "Row" & intRow, "Col" & intCol, .CellBackColor Next Next End With End Sub Private Sub MSFlexGrid1_DblClick() With CommonDialog1 .CancelError = True .ShowColor If Err.Number = cdlCancel Then Exit Sub MSFlexGrid1.CellBackColor = .Color End With End Sub
Regards,




Reply With Quote