3 Replies - 262 Views - Last Post: 19 November 2011 - 08:59 AM Rate Topic: -----

#1 raymai97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 16-November 11

Better method for changing the background of all the button?

Posted 19 November 2011 - 05:13 AM

OK, hope this time will not violate again the rule...

I made a code that will change the background button when the mouse cursor over it, the user press and release it , and it work great...

The code below is a part of the code I made, which will change the background of the button when click by user.

Method to use:
butclick(sender)


Sub butclick(ByVal butname)
'code reset of button background //start//
        Main.bestassi_bluebut_about.BackgroundImage = My.Resources.buttonbg
        Main.bestassi_bluebut_internet.BackgroundImage = My.Resources.buttonbg
        Main.bestassi_bluebut_minitool.BackgroundImage = My.Resources.buttonbg
        Main.bestassi_bluebut_sysadmin.BackgroundImage = My.Resources.buttonbg
        Main.bestassi_bluebut_visual.BackgroundImage = My.Resources.buttonbg
'code reset of button background //end//
        butsel = butname.tag
        butname.backgroundimage = My.Resources.buttonsel
    End Sub


But I had to reset all of the background of the button first, the picture below explain why I need to do like this:
BEFORE ALL BUTTON CLICKED BY USER: Attached Image
IF NOT RESET AND ALL BUTTON CLICKED BY USER: Attached Image
IF WITH RESET: Attached Image

So is there any better code for this? Because my method seen a bit silly. Is there any code that can change the background of all the button in one time?

Is This A Good Question/Topic? 0
  • +

Replies To: Better method for changing the background of all the button?

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5517
  • View blog
  • Posts: 11,826
  • Joined: 02-June 10

Re: Better method for changing the background of all the button?

Posted 19 November 2011 - 05:40 AM

Personally I would use a getter/setter and an enum for the 'mode' of operation.

So all the buttons get reset.
Then if the mode is 'edit' you highlight the 'edit' tab. If the mode is ''English" you highlight the 'English' tab.

What you are dong isn't silly; its fairly common. It's just not in the most logical place.
Was This Post Helpful? 0
  • +
  • -

#3 raymai97  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 16-November 11

Re: Better method for changing the background of all the button?

Posted 19 November 2011 - 06:39 AM

View PosttlhIn`toq, on 19 November 2011 - 05:40 AM, said:

Personally I would use a getter/setter and an enum for the 'mode' of operation.

So all the buttons get reset.
Then if the mode is 'edit' you highlight the 'edit' tab. If the mode is ''English" you highlight the 'English' tab.

What you are dong isn't silly; its fairly common. It's just not in the most logical place.


I'm sorry but I don't understand what are you trying to say. What are you meaning of "If the mode is "english" you highlight the "english" tab."?
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5517
  • View blog
  • Posts: 11,826
  • Joined: 02-June 10

Re: Better method for changing the background of all the button?

Posted 19 November 2011 - 08:59 AM

It was an example. I don't read whatever language is in your screenshots. I don't know if they are indicating modes, languages, options, different data views or what.

As I said what you are doing is fine, I was merely suggesting you move it to a property with a getter and setter.
This puts all the code for mode1 together. Maybe that means selecting one of the buttons you showed and enables certain controls, and hides others as appropriate for that mode.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1