newbie,update splitcontaner back color and save new color

I have 2 forms.

form1 is the main form and options form is the second form.

i have a splitcontainer on form1 with a menu strip that opens options form.

i have a usercontrol on each of the splitcontainer panels.

i have a button on the options form to open a colordialog.

what i would like to do is ,after pressing the ok button on the color dialog,the back color of usercontrol1 of the splitcontainer on form1 would update and save.

after i close and reopen the aplication the last color that i picked would be active.

please see code below it's not working.

it gets as far as opening the color dialog.

after i press ok once it does nothing if i press it again it errors out.

Thanks

publicClass optionsform

Private MyControlbaAs UserControl1

Private MyControlbdAs UserControl2

PrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.Click

SelectTextColor()

EndSub

PrivateSub SelectTextColor()

Dim ColorDialog1AsNew ColorDialog()

ColorDialog1.ShowDialog()

If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OKThen

MyControlbd.BackColor = ColorDialog1.Color

EndIf

EndSub

EndClass

[2782 byte] By [rod_r] at [2007-12-24]
# 1

you need to persist your color change...the easiest way to do this is to use a user setting...

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim ColorDialog1 As New ColorDialog()

ColorDialog1.ShowDialog()

If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

My.Settings.ControlBackGround = ColorDialog1.Color

End If

MyControl.BackColor = My.Settings.ControlBackGround

End Sub

DMan1 at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2

I'm sorry i don't know how to add usersettings.

i copied your sample code and i get an error controlbackcolor is not a member of my.mysettings.

Thanks

rod_r at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

Double click on "MyProject" from the solution explorer....this will open the MyProject window...clcik on the settings tab....Name your setting ("ControlBackColor" in my example) set the scope to "User" set the type to color and then set the initial color

HTH

DMan1 at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 4

ok i created a usersetting named ControlBackColor.

everything looks ok but when i start the debug,i get the following error "argument exemption was unhandled.

here is the code for form1

thanks

Public Class Form1

Private MyControlba As baUserControl

Private MyControlbd As bdUserControl

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

MyControlba = New baUserControl

MyControlbd = New bdUserControl

MyControlba.Parent = SplitContainer1.Panel2

MyControlbd.Parent = SplitContainer1.Panel2

MyControlba.Dock = DockStyle.Fill

MyControlbd.Dock = DockStyle.Fill

MyControlba.Visible = False

MyControlbd.Visible = False

End Sub

Private Sub btnba_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnba.Click

MyControlba.Visible = True

MyControlbd.Visible = False

End Sub

Private Sub btnbd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbd.Click

MyControlba.Visible = False

MyControlbd.Visible = True

End Sub

Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click

optionsform.Show()

End Sub

End Class

rod_r at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 5

I got It,All I had to do is replace

ColorDialog1.ShowDialog()

to

ColorDialog1.AllowFullOpen = True

Thanks

rod_r at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...