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
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
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
Save() (VB.NET) so changes persist across runs. BackColor.ToArgb() (integer) and restore with Color.FromArgb(...). SaveSetting, use a consistent app name and key names. Jump to Post— mustaffa hasan 0form1.bgcolor=vbred
form1.refresh
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.