ParentColor

  • Thread starter Thread starter Alex
  • Start date Start date
Alex said:
Is there a VB equivalent to Delphi's ParentColor property?


Never assign a color to the control's 'BackColor' property, then the
control's background color will stay the same as the containing container's
background color.
 
Herfried K. Wagner said:
Never assign a color to the control's 'BackColor' property, then the
control's background color will stay the same as the containing container's
background color.

Thanks, but I would like to achieve just the opposite. For example:

'***
Public Class Form1

Private Sub Form1_DoubleClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.DoubleClick
Me.BackColor = Color.Yellow ' The form's color changes to Yellow
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
DirectCast(sender, Button).Parent.BackColor = Color.AliceBlue ' The forms
'color changes to AliceBlue
End Sub

End Class
'****

Given the code above , how do I get the button's color to remain its default
gray regardless of the color changes in the form that contains it?
 
Alex said:
Thanks, but I would like to achieve just the opposite. For example:

'***
Public Class Form1

Private Sub Form1_DoubleClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.DoubleClick
Me.BackColor = Color.Yellow ' The form's color changes to Yellow
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
DirectCast(sender, Button).Parent.BackColor = Color.AliceBlue ' The
forms
'color changes to AliceBlue
End Sub

End Class
'****

Given the code above , how do I get the button's color to remain its
default
gray regardless of the color changes in the form that contains it?

Explicitly assign 'SystemColors.Control' to the label's 'BackColor'
property, for example, in the form's constructor after the call to
'InitializeComponent' or the form's 'Load' event handler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top