Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange dataobject with Commandbutton

Status
Not open for further replies.

JohnStep

Programmer
Apr 19, 2000
190
US
<br><br>&nbsp;&nbsp;&nbsp;I am probably overlooking something here but....<br><br>&nbsp;&nbsp;&nbsp;I am trying to change the ForeColor on a Commandbutton. I checked MSDN online and I should beable to do this. Although, when I try to change it with:<br><br>&nbsp;&nbsp;&nbsp;Commandbutton1.ForeColor = &HFF<br><br>&nbsp;&nbsp;&nbsp;I get a datamember not applicable error with the forecolor command??? As well I do not see that Property with the normal Commandbutton options. Although, MSDN online says you can use ForeColor as a property with Commandbutton to change the color of the button's caption. It is probably simple and I am overlooking it... But where am I going wrong. Is there another component elsewhere I have to load to change the color of the buttons caption?<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thanks for the help in advance,<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;John Stephens<br><br>P.S. I have changed Labels forcolor all the time so I know it can be done. Just not with command buttons.
 
I think, probably, MSDN has lied to you in that case, as command buttons don't have a ForeColor property. In fact, I've tried to do this and so has a mate of mine, and there doesn't seem to be any way to change the forecolor of a standard command button.&nbsp;&nbsp;One way to get around it, though, is to make your own, pretend button:<br><br>Draw a button in an art package and save it as a bmp or something similar.<br><br>Put a picturebox control on your form and set it to show the button you've drawn.<br><br>Have whatever you would have had the command button click event do done on the picturebox click event instead.&nbsp;&nbsp;Also, if you change the border style of the picturebox control during the mouse down event to flat (or 2D or something like that) and then back to normal on the mouse up event, it looks like it's being clicked...that's what I did.<br><br>Other than that, there's probably some API call that'll do it, or you might try changing the command button's style from standard to graphical and seeing if it'll let you change its colour then, but I don't think it will.<br><br><br>Oh well, VB eh?<br><br>Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top