Results 1 to 9 of 9

Thread: Button.BackColor & Button.Image Property Issue..

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    252

    Button.BackColor & Button.Image Property Issue..

    HI Friends,
    I am facing one more prob.

    In my Windows application, I want to SET & GET BUTTON'S BACKCOLOR PROPERTY.
    Ofcourse, I can GET backcolor property & save it in DATABASE,
    But I CAN'T SET BACKCOLOR PROPERTY AT RUNTIME.

    can you please tell me how I can SET BACKCOLOR PROPERTY AT RUNTIME [BY USING CODE]

    thank you for your kind help,

    -nanc
    Last edited by NANC; Apr 28th, 2005 at 05:58 PM.

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Button.BackColor GET & SET Property Issue..

    here's how I do it for all of the button controls in a group

    VB Code:
    1. For Each ctl As Control In StrategyBuildergrp.Controls
    2.             If TypeOf (ctl) Is Button Then
    3.                 CType(ctl, Button).BackColor = BUTTON_COLOR
    4.             End If
    5.         Next

    of course if you are changing the color of a single button, then use
    VB Code:
    1. button1.backcolor = system.drawing.color.<somecolor>
    HTH
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    252

    Re: Button.BackColor GET & SET Property Issue..

    Hi Friend,

    Thank you for your kind help.

    As you suggested for ASSIGNING backcolor to button, here is code you suggested.
    ---------------------VISUAL BASIC CODE-------------------
    button1.backcolor = system.drawing.color.<somecolor>
    -----------------------------------------------------------
    my prob. is <somecolor> value will come from database which is in STRING format. And thats the only reason it dosen't work, how can I convert STRING in to COLOR ENABLED OBJECT ????

    I hope, I explained well my prob.

    thank you,

    - nanc

  4. #4
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Button.BackColor GET & SET Property Issue..

    provided the string is a valid color name you can use something like

    VB Code:
    1. Dim MyColor As String = "Gray"
    2.         Button1.BackColor = Color.FromName(MyColor)
    HTH
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    252

    how to get Button.Image name

    Hi Friend,

    thank you for your help, it works.

    but I got caught in another tiny matter,

    HOW CAN I GET BUTTON.IMAGE NAME AT RUNTIME.

    I am hopeful that you know the answer.
    thank you,

    -nanc

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    252

    Re: Button.BackColor & Button.Image Property Issue..

    Hi friends,

    I think, I didn't explain my prob.

    In my app., I creat COMMAND BUTTON at runtime and assign/SET property values.
    I also retrive/GET property values like BUTTON.TEXT, BUTTON.BACKCOLOR, and BUTTON.IMAGE...
    I can't get BUTTON.IMAGE name in text or any other form. I want to store BUTTON.IMAGE NAME IN DATABASE IN TEXT FORM.

    can you pls help me out getting such matter done..

    thank you,

    -nanc

  7. #7
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Button.BackColor & Button.Image Property Issue..

    I'm not sure you can get the image name from the button.image per se. If you set the image in your code, then maybe you can also set the button tag proerty to your image name.
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Posts
    252

    Re: Button.BackColor & Button.Image Property Issue..

    Its true that I can get image name from button tag property while loading button.
    but, user may change image runtime, so how code can find that user has changed image & which one is the latest image.

    ???
    little confused.

    may be your little help makes a big result here.

    -nanc

  9. #9
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Button.BackColor & Button.Image Property Issue..

    Is it in your code that the user will change the image? If so, then when he/she changes the image then you can reset the tag property at the same time. It still may be possible to get the image name at run time, but I just don't know how.
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

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