I want to change form background color permanently at run time. when i start my application next time then i want to see the changed color

please help

thanks in advance

Dani AI

Generated

Persisting a runtime BackColor means saving the chosen color somewhere and restoring it when the form loads. showed how to change the form color at runtime and suggested persisting it; below are two practical ways (VB.NET and classic VB) with short, copy-paste-ready examples and a few tips.

VB.NET (recommended: user-scoped setting)
Create a user-scoped setting named FormBackColor of type System.Drawing.Color in Project > Properties > Settings. Save when the user picks a color and restore on load:

' Save (after user changes color)
My.Settings.FormBackColor = Me.BackColor
My.Settings.Save()

' Restore (Form_Load)
If My.Settings.FormBackColor <> Color.Empty Then
    Me.BackColor = My.Settings.FormBackColor
End If

See the application settings overview for details: Application settings overview.

VB6 (simple registry-style storage)
Use SaveSetting / GetSetting to write a small value into per-user storage:

' Save
SaveSetting "MyApp", "Appearance", "BackColor", CStr(Me.BackColor)

' Load (Form_Load)
Dim s As String
s = GetSetting("MyApp", "Appearance", "BackColor", "")
If s <> "" Then
    Me.BackColor = CLng(s)
End If

Docs: and .

Notes and troubleshooting

  • Always call Save() (VB.NET) so changes persist across runs.
  • If you prefer not to use a Color-typed setting, store BackColor.ToArgb() (integer) and restore with Color.FromArgb(...).
  • With SaveSetting, use a consistent app name and key names.
  • For roaming/multi-machine scenarios, store settings in a file, database, or cloud service rather than per-user registry.

Recommended Answers

All 2 Replies

form1.bgcolor=vbred
form1.refresh

Save background color changed into txt files or you can use registry instead of txt files. Load it when form load.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.