Windows Develop Bookmark and Share   
 index > Windows Forms General > please help with my colour button's icon
 

please help with my colour button's icon

How can I make it so the icon for my colour button will automatically change icons, depending on the clicked colour, or selected text of my program? Example if I click on a part of my program's text that is red, the colour icon will change to red. How do I do this?
TheTrueFace  Friday, April 04, 2008 6:08 AM

I'm not sure how you have your button set up, but I'm guessing you want to get a graphics object corresponding to the button, or a portion thereof, create a brush with the color that was selected, and then fill in a particular rectangle (your icon) with the color you want to use.

Classes that would correspond to this would be:

Graphics

Image

Brush

Pen

Rectangle

Point

All of these are in the System.Drawing namespace.

If you post some of your own code, it might be easier for people to help you.

David M Morton  Saturday, April 05, 2008 11:23 AM

if you are using a button control to trigger event of changing the color of another control then you have to work inside the event of the button.

try to do this one and test.

1. drag a button and a panel to your form.

2. double click the button and add this code. your code should look like this..

private void button3_Click(object sender, EventArgs e)

{

this.panel1.BackColor = System.Drawing.Color.Red;

}

now play around from here to meet your requirements.

Bermil M. Espina  Friday, April 04, 2008 6:14 AM
That isn't even close to what I am asking for. I wanted the icon to change to red when the colour red was selected... how does your code help me in any way at all??? Please only reply to the topic if you know you can help me effictively.
TheTrueFace  Saturday, April 05, 2008 6:30 AM

I'm not sure how you have your button set up, but I'm guessing you want to get a graphics object corresponding to the button, or a portion thereof, create a brush with the color that was selected, and then fill in a particular rectangle (your icon) with the color you want to use.

Classes that would correspond to this would be:

Graphics

Image

Brush

Pen

Rectangle

Point

All of these are in the System.Drawing namespace.

If you post some of your own code, it might be easier for people to help you.

David M Morton  Saturday, April 05, 2008 11:23 AM

You can use google to search for other answers

Custom Search

More Threads

• Textbox on MDI Form. Strange Selection / Cursor Behaviour
• One form waiting on another
• Cannot add an inherited winform
• I can’t persist the command properties of my dataadapter between calls to the data layer class.
• MDIChild Menu problem...
• Menu bar & status bar controls
• Check box within MenuStrip displays too large
• Adding selected ListBox Items to an ArrayList?
• Modeless window does not lose focus
• How to Change WinForms Buttons BackColor ?