none
VB.NET Label and TextBox Colors Different RRS feed

  • Question

  • Working on creating and Windows Form App in Visual Studio 2019. Having a minor issue with Control.Forecolor.  I can set the color off the Controls, that is not a problem.  The Problem is the Colors do not match and the only "Difference" is the Size of the Font.  In particular I have 2 Labels, one right above the Other.  Top Label is Sized 250,38 and has Font set as San Serif at Size 18.  Bottom Label is Sized 250,120 and has Font set as San Serif at Size 55.  Not that it make any difference, but depending on what is going on in other parts of the Program the Forecolor is set to either Color.Green, Color.Yellow, or Color.Red. (and no it is not a Stop Light) :)  No matter which "Color" they are Set to, the Bottom Label is "Lighter" than the Top Label.  Just in case, I have used ToolTips on the Controls while the App was running and Verified that the A, R, B, and G Parameters of the ForeColor are Identical between the 2 Labels.  Yet the Displayed Color is noticeably different.  Anyone else seen this, or have a fix?


    • Edited by Rascle1 Wednesday, July 17, 2019 12:00 AM
    Wednesday, July 17, 2019 12:00 AM

Answers

  • Hi,

    see my code,I don't seem to reproduce your issue.

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Label1.Size = New Size(250, 38)
            Label1.Font = New Font("San Serif", 18)
            Label1.ForeColor = Color.Red
            Label1.Text = "TestLabel"
            ToolTip1.SetToolTip(Label1, Label1.ForeColor.R & " " & Label1.ForeColor.G & " " & Label1.ForeColor.B)
    
            Label1.Size = New Size(250, 120)
            Label2.Font = New Font("San Serif", 55)
            Label2.ForeColor = Color.FromArgb(255, 64, 64)
            Label2.Text = "TestLabe2"
            ToolTip1.SetToolTip(Label2, Label2.ForeColor.R & " " & Label2.ForeColor.G & " " & Label2.ForeColor.B)
        End Sub
    
    
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Rascle1 Saturday, July 27, 2019 10:03 AM
    Wednesday, July 17, 2019 1:58 AM
    Moderator

All replies

  • Hello,

    Going with the information provided, using these facts.

    • Try running the app on another computer to rule out display drivers being the issue.
    • Try doing this in a new project without doing anything other than setting colors.

    It also may be a bug, you can always report it to Microsoft using the feedback link at the top of the IDE.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, July 17, 2019 12:34 AM
    Moderator
  • Hi,

    see my code,I don't seem to reproduce your issue.

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Label1.Size = New Size(250, 38)
            Label1.Font = New Font("San Serif", 18)
            Label1.ForeColor = Color.Red
            Label1.Text = "TestLabel"
            ToolTip1.SetToolTip(Label1, Label1.ForeColor.R & " " & Label1.ForeColor.G & " " & Label1.ForeColor.B)
    
            Label1.Size = New Size(250, 120)
            Label2.Font = New Font("San Serif", 55)
            Label2.ForeColor = Color.FromArgb(255, 64, 64)
            Label2.Text = "TestLabe2"
            ToolTip1.SetToolTip(Label2, Label2.ForeColor.R & " " & Label2.ForeColor.G & " " & Label2.ForeColor.B)
        End Sub
    
    
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Rascle1 Saturday, July 27, 2019 10:03 AM
    Wednesday, July 17, 2019 1:58 AM
    Moderator
  • Thank you. Tried pasting Images of what I was seeing but am unable. :(  As I indicated above in my reply to Karen, I should be able to use the ARGB Codes, as you have shown in your code, to at least work around the Issue.  After verifying the problem is an actual issue, per Karen's Suggestion of trying on another PC/Laptop, and not something specific to my Laptop.  I will return and mark the appropriate Answer once I have had a chance to test on another System.  Thank you both for the Responses/Assistance.
    • Edited by Rascle1 Friday, July 19, 2019 11:06 PM
    Friday, July 19, 2019 10:18 PM
  • I will Install my app on another System and get back to you. I did try a New Project, using Alexes Code Below both as posted and changing the Second Label to Color.Red.  Was just going to post that the results were the same, but it is definitely weird.  In the case of Alex's Code, the Smaller Label is Lighter where in my original Code/App the Larger Label was Lighter.  I have been able to figure that part out and things get even stranger.  Did not realize it would make a difference/change things, but if the Form Background is White (as the New Project started out as) the Smaller Label was Lighter but if the Background is Black (as it is in my Project and same thing when I changed the New Project to use a Black Background for the Form) the Larger Label is Lighter.  Will still have to see what happens on another PC, but I am thinking there is probably no way to fix this directly.  Providing the Secondary PC/Laptop exhibits the same phenomenon I think I may have come up with a workaround to at least get the App "look" correct even though the actual Code/Values would be incorrect.  Through some Trial and Error I should be able to Adjust the ARGB Values and make the Labels at least "Appear" to be the same color.  Thanks for the insights and thoughts. 
    Friday, July 19, 2019 10:46 PM
  • Hi

    Twopence worth! My Window 10 system has some Night effect options that do adjust the screen brightness and perhaps colours during day/night cycle - could something like that be playing a part in what you are seeing?


    Regards Les, Livingston, Scotland

    Friday, July 19, 2019 10:56 PM
  • Leshay: I would think something like that would affect Both Labels the same. In my case, some Labels that are set to the same color are visibly different on the screen.  This is not a situation where they change colors, this is where they are visibly different at the same time.  Across multiple runs the Colors are always the same (ie some are darker some are lighter).  They do however change which ones are Light and Dark if I change the Background Color, and swapping back and forth between the 2 Background Colors the causes the same Labels to be Light/Dark.

     Karen: I have finally been able to Test it on multiple systems, both Win7 and Win10, with the same results.  So not anything with my Laptop causing it.  I also see the same thing connected via HDMI to a HD TV.  Same thing with a New Project with just the 2 Labels and Code to set the Color, Sizes, etc (Alex's Code).

    Alex: Not sure it is what you intended but your suggestion helped.  Have not had a chance to do it but I should be able to "Manually" set the Colors via ARGB Codes to get the Labels to Visually Match.


    Thanks all for the Ideas/Suggestions. 

    Saturday, July 27, 2019 10:03 AM