|
-
Jan 20th, 2006, 08:41 AM
#1
Thread Starter
Member
change listbox's bgcolor
hey!
i have this code in form2 :
VB Code:
Dim main As New Form1
main.win.BackColor = main.win.BackColor.Black 'win is a listbox control
but it doesnt works and i dont know why 
(when i try me.win.BackColor = me.win.BackColor.Black in the form1 it works)
Thanks!
Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.
-
Jan 20th, 2006, 09:06 AM
#2
Fanatic Member
Re: change listbox's bgcolor
main.win.BackColor = System.Drawing.Color.Black
-
Jan 20th, 2006, 06:01 PM
#3
Thread Starter
Member
Re: change listbox's bgcolor
Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.
-
Jan 20th, 2006, 06:11 PM
#4
Frenzied Member
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.
-
Jan 20th, 2006, 06:14 PM
#5
Thread Starter
Member
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!
Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.
-
Jan 20th, 2006, 06:21 PM
#6
Frenzied Member
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
-
Jan 20th, 2006, 06:29 PM
#7
Thread Starter
Member
Re: change listbox's bgcolor
this is what error i get:
'Set' parameter must have the same type as the containing property.
Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.
-
Jan 20th, 2006, 07:15 PM
#8
Frenzied Member
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
-
Jan 21st, 2006, 03:08 AM
#9
Thread Starter
Member
Re: change listbox's bgcolor
i found another way, but yours also helped 
thanks!
(HAHA im gonna rate you )
Human beings are a disease, a cancer of this planet, you are a plague, and we are the cure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|