Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Button colour should change after selecting the button

Hi Guys,,

               In my report i have 3 buttons and some objects are linked to these buttons.My requirement is if i click on one button that button clour should change ,,, if i click on second button that colour should change...... i.e we can easily idetify that the button is active, for this i have written a below macro but its not working so please give me ypour suggestions what is wrong here........

sub activate3

set ITMHierarchy=activedocument.getsheetobject("BU07")

set prop= ITMHierarchy.getproperties

prop.bkgcolor.primarycol.col=rgb(0,255,0)

ITMHierarchy.setproperties prop

set ITMHierarchy=activedocument.getsheetobject("BU08")

set prop= ITMHierarchy.getproperties

prop.bkgcolor.primarycol.col=rgb(128,128,128)

ITMHierarchy.setproperties prop

set ITMHierarchy=activedocument.getsheetobject("BU09")

set prop= ITMHierarchy.getproperties

prop.bkgcolor.primarycol.col=rgb(128,128,128)

ITMHierarchy.setproperties prop

end sub

sub activate4

set ContractualPortfolio=activedocument.getsheetobject("BU08")

set prop= ContractualPortfolio.getproperties

prop.bkgcolor.primarycol.col=rgb(0,255,0)

ContractualPortfolio.setproperties prop

set ContractualPortfolio=activedocument.getsheetobject("BU07")

set prop= ContractualPortfolio.getproperties

prop.bkgcolor.primarycol.col=rgb(128,128,128)

ContractualPortfolio.setproperties prop

set ContractualPortfolio=activedocument.getsheetobject("BU09")

set prop= ContractualPortfolio.getproperties

prop.bkgcolor.primarycol.col=rgb(128,128,128)

ContractualPortfolio.setproperties prop

end sub

sub activate5

set OperationalPortfolio=activedocument.getsheetobject("BU09")

set prop= OperationalPortfolio.getproperties

prop.bkgcolor.primarycol.col=rgb(0,255,0)

OperationalPortfolio.setproperties prop

set OperationalPortfolio=activedocument.getsheetobject("BU08")

set prop= OperationalPortfolio.getproperties

prop.bkgcolor.primarycol.col=rgb(128,128,128)

OperationalPortfolio.setproperties prop

set OperationalPortfolio=activedocument.getsheetobject("BU07")

set prop= OperationalPortfolio.getproperties

prop.bkgcolor.primarycol.col=rgb(128,128,128)

OperationalPortfolio.setproperties prop

end sub

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi Anil,

Please find the attachment, it consists of buttons with the colors as specified by you.

=If(vButton = 1, RGB(255, 0, 0), RGB(0,0,255))

The above expression changes Button 1 color to Red(RGB(255, 0, 0)) on clicking button1, if any other button is clicked it is modified to Blue(RGB(0,0,255)).

On clicking the first button i modify the variable vButton value to 1 by using Button  Properties -> Action -> Set Variable

Color code for Gray is RGB(192, 192, 192), you can refer for color code online.

Hope this helps you.

Regards,

Jagan.

View solution in original post

9 Replies
Not applicable
Author

jagan
Luminary Alumni
Luminary Alumni

Hi,

Check the attachment I created 3 buttons, and a variable.  On clicking a button I am modifying the variable value by using the Action -> External -> Set Variable and in General table added the disable condition

For Button1

=If(vButton = 1, 0,1)

Regards,

Jagan.

jagan
Luminary Alumni
Luminary Alumni

You can also change button color by using following expression in

Properties -> Color -> Calculated

=If(vButton = 1, RGB(255, 0, 0), RGB(0,0,255))

Regards,

Jagan.

Not applicable
Author

Guys  thanx for your replies,, i have tried to implement your example where to apply the colour for button am not able to find this property  Properties -> Color -> Calculated

am using QV10 version and am new to QV also:):)

Marc i will try your example also tonight

jagan
Luminary Alumni
Luminary Alumni

Hi Anil,

I am currently using QV 9, I am attaching the screenshot in QV9.

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi Jagan,

            It is working almost as i want , and when i click on the button that button colour should change to blue and remaining two button will have some other colour lets take it as light gray colour for that what is the RGB code and how to write it....

           In your example once we  click on the button that colour changing from blue colour to light gray colour.

and please explain this  " =If(vButton = 1, RGB(255, 0, 0), RGB(0,0,255))" how it is working in QV

     

Regards,

Anil

jagan
Luminary Alumni
Luminary Alumni

Hi Anil,

Please find the attachment, it consists of buttons with the colors as specified by you.

=If(vButton = 1, RGB(255, 0, 0), RGB(0,0,255))

The above expression changes Button 1 color to Red(RGB(255, 0, 0)) on clicking button1, if any other button is clicked it is modified to Blue(RGB(0,0,255)).

On clicking the first button i modify the variable vButton value to 1 by using Button  Properties -> Action -> Set Variable

Color code for Gray is RGB(192, 192, 192), you can refer for color code online.

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi Jagan now its perfectly working thaks a lot..............

i have another issue i will post it today..please look in that also

Not applicable
Author

Hi  Jagan i have another issue....

              I have some tables..........

   1) AppServer Table

            --Server ID

            --Appl ID these are columns

  2) Server Table

          --Server ID

         -- server name.........etc some other columns

  3) Software Tabke

              -- server ID

              --software name

             -- software name....etc

  4) Apptech Table

             --Appl ID

             --Appl Name...etc

like this i have some other tables using these tables i have created some charts and tables.

From charts if i select server name it is updating with what all are the server softwares and application under that server and

if  i select applname from any object charts should update with whatall are the softwares using for that application and it should updatewith related servers but it is not updated with the related details. soplease give me your suggestions.

sorry due to some reasons am not able togive the sample file or data

Regards,

Anil