Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows Forms WinForm
Hi Code Project readers,
 
I dont know how to change the background color of the toolstrip buttons when it is clicked...
 
I have 6 buttons in the toolstrip. when i click the 3rd button, that button alone need to be highlighted, till the next button is clicked.
 
Thanks in Advance.
Posted 10-Apr-13 2:08am
Velrats1.3K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Step 1. Create click event handlers for each button.
Step 2. For the 5 buttons, add code that de-highlights button #3.
Step 3. On the handler for button #3, add code that highlights the button (and possibly de-highlights all the others)
 
Hope this is what you meant. Smile | :)
  Permalink  
Comments
Velrats at 10-Apr-13 7:55am
   
yes i too know... but i need the exact code... I'm a newbie in programming.. so please dont hesitate to let me know the exact code for that...
i trying many but nothing works...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You need to assign below event as click event for all the toolstrip buttons.
 
Color NormalColor = SystemColors.Control;
Color HighlightColor = Color.Orange;
 
private void ToolStripButton_Click(object sender, EventArgs e)
{
    ToolStripButton tsbtnTemp = sender as ToolStripButton;
 
    toolStripButton1.BackColor = NormalColor;
    toolStripButton2.BackColor = NormalColor;
    toolStripButton3.BackColor = NormalColor;
    toolStripButton4.BackColor = NormalColor;
    toolStripButton5.BackColor = NormalColor;
    toolStripButton6.BackColor = NormalColor;
 
    tsbtnTemp.BackColor = HighlightColor;
}
  Permalink  
v2
Comments
Velrats at 17-Apr-13 5:52am
   
Thanks a lot for the snippet... it works.... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Marcin Kozub 275
1 OriginalGriff 264
2 Sergey Alexandrovich Kryukov 215
3 Praneet Nadkar 197
4 Richard MacCutchan 182
0 OriginalGriff 8,048
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 17 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100