How to make a button appear as if it is pressed? - c#

Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button look "pressed"?
Imagine this button is an on/off switch.
ToolStripButton has the Checked property, but the regular Button does not.

One method you can used to obtain this option is by placing a "CheckBox" object and changing its "Appearance" from "Normal" to "Button" this will give you the same functionality that I believe you are looking for.

You could probably also use the ControlPaint class for this.

I think you may need a ToggleButton. You can take a look at third party vendors of WinForms components such as Telerik, DevExpress, ComponentFactory, ViBlend which provide such control. They all provide toggle buttons.

Related

Using CommandBar to customize ribbon in COM-Addin

I am trying to add a button to the ribbon using CommandBars, but I can't find any example or a way to do that.
I cannot use the CustomUI XML because I need to change the visibility of the button, and it is not supported by the CustomUI XML.
I have found a CommandBar called "Ribbon" with a CommandBarControl that is called "Ribbon" as well, but I don't see how I use it to place a button on "TabHome".
Does anyone know what am I missing here? or can point me out to an example?
Thanks!
As far as I know, you can't use CommandBars to control ribbon. And it makes no sense to do so, as CommandBars technology is depreciated for ribbon ui, and basically supported for compatibility only.
Did not quite get why you don't want to use ribbon xml to customize ribbon? It's the official way. To control button visibility, you should simply set a "getVisible" attribute of the button to your event handler (callback) and and in that callback return true/false to show/hide the button...
What you can't show/hide dynamically are built-in office buttons, but you should be able to show/hide your own buttons without any issues.
Looks quite similar to this one:
Is there a way to use VBA and XML to add a button to the Office 2010 Ribbon depending on a string in the file name?

How to change windows control panel settings through C#

More specifically I want to change Visual Effects. My goal is to press a button then have it change the 15 visual effects. Such as turning off "drop shadow" and disabling "fade/slide menus into view." I did a ton of searching and the only thing I accomplished is how to find out if it is enabled with something like this:
dropshadow = SystemInformation.IsDropShadowEnabled;
MessageBox.Show("Drop Shadow enabled:"+Convert.ToString(dropshadow));
This is for C#
I think you will need to use pinvoke to achieve this.
Have a look at http://support.microsoft.com/kb/97142
And here is a c# example http://www.pinvoke.net/default.aspx/user32.systemparametersinfo
Not sure if this covers everything you want, but should cover most.
This is what SystemInformation uses under the hood, I believe.

Any .NET Winforms control which look like this QT's QPushButton?

Is someone know any .NET Winform control which look like this button control?
QPushButton:
http://zetcode.com/gui/csharpqyoto/layoutmanagement/
You have several options here. You aren't specific about exactly which part of the platform you are using, but if using Winforms, you can certainly customize the buttons to some extent.
If you are using WPF, you can pretty much make it look exactly like you want in XAML. Check out Expression Blend.
As #Dimitri put it, the sky is the limit, but you may need to do the leg work.
You can create custom controls according your need and have its reference added to your project. you will have it added to your toolbox that you can use.
If you are refering to a button that is located on this example form:
We currently finishing our own application that has rather similar looking buttons. We did this by using a third party component. Steps are:
We purchased DevExpress.com's WinForms library.
We developed our own DevExpress Skin (with the help of an external screen design guy)
This was a bit of a work and some amount of money but the results look pretty neat.

C# Volume mixer like buttons/combo boxes

How would you get a button to look and perform similar to that of the buttons in the volume mixer on Win7?
What I mean is that in the volume mixer there are icons that doesn't look like buttons until you hover them, they also haven't got the standard blueish color when hovered.
So far I haven't found a way to do this directly in visual studio.
I'm guessing that creating a custom user control is the only way to go, but I've had no luck so far, I would appreciate some examples.
In addition, there are also combo boxes in the volume mixer I would like to duplicate. They're hidden except for the text and arrow until they're hovered.
Is there a way to accomplish this?
(Here an image that might help explain what I mean:
http://i53.tinypic.com/2ij409u.png)
For windows application, (and also how they did win7), they used the technology called WPF. I am not specifically answering how you can do this, because in WPF, this is the fundamental that defining skin (via markup called XAML) without touching the implementation code. If you are serious in learning how to do that, I suggest you look for tutorials or good book about WPF.
Here's one of the markup looks like for a button. To modify the button's look, what you need is to define it's XAML, and you don't have to inherit it in the code. The example looks scary long, but Visual Studio could help you.
You could use a third party control library, for example Krypton Toolkit, its free!
There is quite a terrific solution for this button quest. You can paste pictureBoxes on form and handle MouseUp, MouseLeft and MouseDown events. When each of them fires, you need to set specific image (one of tree, in fact) - normal picture, picture of "highlighted" icon and picture of pressed icon. But that's really a hard and useless work, so better don't.
If you need several of such "buttons" in a panel, I remember, I once managed to get the same behaviour by using toolStrip with buttons.

How to make a tab's name editable in C#?

So I have a few tabs in the form, and i want it to work like that:
When you click on the tab's name, it becomes editable, and when i stop editing it remains with the new name.
How would i do that with C# and winforms?
You can dynamically create a text box and place it over the tab area to make the user think they are editing the tab directly. When the text box loses focus you can then put the typed in value into the tabs property.
I agree with Eric, regarding how you could do this with the standard TabControl. You could also provide a dialog to do the name change (a slight variation on Eric's suggestion).
However, I would also recommend that you consider rolling your own tabbed control. They're not difficult to create and by rolling your own, you will be able to put in the exact functionality you need in a robust way rather than trying to piece it together from existing components that may not play nicely together.
There's no standard Windows control that does this, so you'll either need to look for a third-party control with this functionality (iffy) or write your own control which draws the appropriate edit box on the tab, etc.

Categories

Resources