Results 1 to 6 of 6

Thread: Setting label backcolor in colde

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    36

    Question Setting label backcolor in colde

    Can anyone tell me why this bit of code does not change the background color of the label?

    Label1.BackColor = Color.FromArgb(QBColor(Val(sender.tag)))

    This line is executed from within an event procedure that is called when a button is clicked (it's actually a 4x4 matrix of buttons, each tagged with a number 0 to 15). I have viewed the result of the .FromArgb method in the debug window, and it returns the correct value for the corresponding QBColor, but for some reason it does not change the background color of the label. Am I missing something here (maybe using the Argb method incorrectly), is there another way of doing this, or ????????

    --Steve
    [email protected]

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    This is from MSDN:
    argb
    A value specifying the 32-bit ARGB value.

    Return Value
    The Color structure that this method creates.

    Remarks
    The byte-ordering of the 32-bit ARGB value is AARRGGBB. The most significant byte (MSB), represented by AA, is the alpha component value. The second, third, and fourth bytes, represented by RR, GG, and BB, respectively, are the color components red, green, and blue, respectively.
    so in your method the 'alpha' value may be 0, so it wont have any effect.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    36
    I see that now - in the debug window, regardless of which button I click, the alpha value returned is '0', which I assume is transparent. So, now the question is, how do I change that alpha value to 255? Or would it be easier to use the tag for each button differently so that I didn't have to convert from a QBColor?

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I think setting the tag to the color value would be less pain than converting.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2001
    Posts
    36
    Yes, this is true. Any suggestions for doing this automatically with a loop in code, or would it just be easier to set the tag property to the value by hand?

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Hmm , Why don't you use something similar to this :
    VB Code:
    1. Button1.BackColor = Drawing.Color.AnyColor
    I think this would be less pain at least .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width