BackColor behaviour also crazy

  • Thread starter Thread starter C
  • Start date Start date
C

C

Changing the background colour of a Form changed the background colour
of several controls on it, as if they were transparent. I think this
change from VB6 is quite crazy, and I wonder if there are simple ways
around this.

The only thing I can think of is to change the colour of all controls
in a For loop - not a very decent solution, but Microsoft seems to do
a lot of illogical things - user hostile.

Something like

Dim ctrl As Control
For Each ctrl In Form1.Controls
If Type ctrl Is button Then ctrl.BackColor =
Color.FromArgb(128, 255, 92)
If Type ctrl Is label Then ctrl.BackColor =
Color.FromArgb(128, 128, 128)
Next
 
Am 01.08.2010 21:17, schrieb C:
Changing the background colour of a Form changed the background colour
of several controls on it, as if they were transparent. I think this
change from VB6 is quite crazy, and I wonder if there are simple ways
around this.


See 2nd paragraph in the "remarks" section

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.backcolor.aspx

and the (therein linked) 3rd paragraph here

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx

about "ambient properties".

The only thing I can think of is to change the colour of all controls
in a For loop - not a very decent solution, but Microsoft seems to do
a lot of illogical things - user hostile.

Well, I am happy that I don't have to manually change the colors
of all controls if I change the Form color because it's done
automatically. ;-)
Something like

Dim ctrl As Control
For Each ctrl In Form1.Controls
If Type ctrl Is button Then ctrl.BackColor =
Color.FromArgb(128, 255, 92)
If Type ctrl Is label Then ctrl.BackColor =
Color.FromArgb(128, 128, 128)
Next

You can also select multiple controls in the designer, then set
their backcolor properties in one go.
 
Am 01.08.2010 21:17, schrieb C:


See 2nd paragraph in the "remarks" section

http://msdn.microsoft.com/en-us/library/system.windows.forms.control....

and the (therein linked) 3rd paragraph here

http://msdn.microsoft.com/en-us/library/system.windows.forms.control....

about "ambient properties".

I read it. New way of thinking.
Well, I am happy that I don't have to manually change the colors
of all controls if I change the Form color because it's done
automatically. ;-)

You have a point. For labels and check boxes this might be a good
thing. For some other controls, may be not.
You can also select multiple controls in the designer, then set
their backcolor properties in one go.

This too is nice. I have all commands in one column, so it will be
easy to pick all of them with the arrow without getting other things
in the selection.

Thanks.
 
Back
Top