|
-
Jul 13th, 2000, 02:09 AM
#1
Thread Starter
New Member
HI,
I WANT TO KNOW HOW TO CHANGE THE BACK COLOR OF THE BUTTON AT RUN TIME.
I AM CREATED BUTTON ARRAY WITH 5 BUTTONS.
LIKE CMDSAVE(0),CMDSAVE(1),CMDSAVE(2),...CMDSAVE(5)
WHEN I CLICK THE CMDSAVE(0) THIS BUTTON BACKGROUND COLOR SHOULD BE CHANGE INTO RED COLOR AND ALL OTHER BUTTONS BACK GROUND COLOR SHOULD BE WHITE.
AND AFTER THIS I PRESSED THE CMDSAVE(1) THEN CMDSAVE(1) BUTTON BACKGROUND COLOR RED AND CMDSAVE(0) BACK COLOR WHITE
AND ALL OTHER BUTTONS COLOR WHITE.
WHEN EVER USER CLICKS A PARTICULAR BUTTON THAT BUTTON COLOR CHANGES TO RED AND REMAINING INTO WHITE.
BYE.
-
Jul 13th, 2000, 02:17 AM
#2
Thread Starter
New Member
HI,
I WANT TO KNOW HOW TO CHANGE THE BACK COLOR OF THE BUTTON AT RUN TIME.
I AM CREATED BUTTON ARRAY WITH 5 BUTTONS.
LIKE CMDSAVE(0),CMDSAVE(1),CMDSAVE(2),...CMDSAVE(5)
WHEN I CLICK THE CMDSAVE(0) THIS BUTTON BACKGROUND COLOR SHOULD BE CHANGE INTO RED COLOR AND ALL OTHER BUTTONS BACK GROUND COLOR SHOULD BE WHITE.
AND AFTER THIS I PRESSED THE CMDSAVE(1) THEN CMDSAVE(1) BUTTON BACKGROUND COLOR RED AND CMDSAVE(0) BACK COLOR WHITE
AND ALL OTHER BUTTONS COLOR WHITE.
WHEN EVER USER CLICKS A PARTICULAR BUTTON THAT BUTTON COLOR CHANGES TO RED AND REMAINING INTO WHITE.
BYE.
-
Jul 13th, 2000, 02:20 AM
#3
Fanatic Member
Ok,
Put this under the CommandSave_Click()
Code:
CommandSave.BackColor = &H000000FF& 'red
CommandSave1.BackColor = &H00FFFFFF& ' white
CommandSave2.BackColor = &H00FFFFFF& 'white
CommandSave1_Click()
CommandSave1.BackColor = &H000000FF& 'red
CommandSave.BackColor = &H00FFFFFF& ' white
CommandSave2.BackColor = &H00FFFFFF& 'white
You also have to chage the "Style" of the Command buttons to Graphical by going into the properties and scrolling to "style"
is this undertandable?
I hope so.
Gl,
D!m
-
Jul 14th, 2000, 01:02 AM
#4
Thread Starter
New Member
yah,
i did same way,
but it's very long code we want to write.
i request u to any other method for to achieve same function.
becasue everytime we want to change the color of one button and same time other button's color.
bye
-
Jul 14th, 2000, 01:23 AM
#5
Fanatic Member
Well i guess you can use If Then statements...but that could take just as much code if not more.
Code:
If Command1.BackColor= Blah Then
Command2.BackColor= Bla
Command3.BackColor= Blah
Else
Command1.BackColor=Blah
End If
I hope you get the idea...If you have 3 command buttons then it would take 3 If Then statents.
So i would go with the previous post.
Gl,
D!m
-
Jul 14th, 2000, 08:10 AM
#6
Another method is to loop through all of the Buttons.
Code:
Private Sub cmdSave_Click(Index As Integer)
'If cmdSave(0) is presed
If Index = 0 Then
'Change cmdSave(0) Backcolor to Red
cmdSave(0).BackColor = vbRed
'Loop through the rest of the Controls in the Array and change their
'Backcolor to white.
For I = 1 To 5
cmdSave(I).BackColor = vbWhite
Next I
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|