Re: change listbox's bgcolor
main.win.BackColor = System.Drawing.Color.Black
Re: change listbox's bgcolor
Re: change listbox's bgcolor
I think the issue is that you are creating a new instance of form1.
I am assuming that form1 opened form2 then an event occurs on form2 that cause the listbox on form1 to change colors.
There are a few ways to do this.
If the list box needs to change colors instantly you need to pass a reference of form1 to form2.
if the listbox doesn't need to change until after form2 closes you can have some sort of flag.
If I assume correctly tell me what needs to happen and if you need an example I will give you one. Or if I assumed wrong. Tell me exactly what you are trying to do.
Re: change listbox's bgcolor
i open the form2 with ShowDialog(), and i want to change the color of the listbox in form1.
it doesn't matter if it changes imediately or after form2 is closed...
thanks!
Re: change listbox's bgcolor
On form2 create a color property. Then after the dilog closes set the listbox to that color
VB Code:
'on Form2
' both the private variable and the propertery are declared at the class level
Private _listBoxColor as Color = Color.White
Public Property ListBoxColor
Get
Return _ListBoxColor
End Get
Set(value As Color)
_ListBOxColor = Value
End Set
End Property
'then where you have
'main.win.BackColor = main.win.BackColor.Black 'win is a listbox control
_ListBoxColor = Color.Black
'Form1 Class
frm2.ShowDialog
win.BackColor = frm2.ListBoxColor
Re: change listbox's bgcolor
this is what error i get:
'Set' parameter must have the same type as the containing property.
Re: change listbox's bgcolor
Upps sorry.
declare the property like this
VB Code:
Public Property ListBoxColor [B]As Color[/B]
'everything else the same
Re: change listbox's bgcolor
i found another way, but yours also helped ;)
thanks!
(HAHA im gonna rate you :D)