take away its prozac ?
no seriously
I want to drop a button onto a form, then during runtime, when user
clicks the button it stays in the "depressed" image state (with a new
color) then when it is pressed again it pops up to its normal state
and color
and of course i want to execute code on each push down and pop up
any idea how this can be done please.
Also a way to make an array of such depresseable buttons, that
function like an array of radio buttons in that only 1 on the panel is
ever selected at any one time
thanks for any advice
Peted 2 16852
One way os to use the ControlPaint class and draw the button yourself.
public class ToggleButton : Button
{
public ToggleButton()
{
SetStyle(Contro lStyles.UserPai nt, true);
}
protected override void OnPaint(PaintEv entArgs pevent)
{
// base.OnPaint(pe vent);
ControlPaint.Dr awButton(pevent .Graphics,
this.ClientRect angle, toggleState);
using (Brush b = new SolidBrush(Fore Color))
{
SizeF sz = pevent.Graphics .MeasureString( Text, Font);
float x = Math.Max(2, (ClientSize.Wid th - sz.Width) /
2);
float y = Math.Max(2, (ClientSize.Hei ght -
sz.Height) / 2);
pevent.Graphics .DrawString(Tex t, Font, b, x, y); //
draw the text on the button
}
}
protected override void OnClick(EventAr gs e)
{
base.OnClick(e) ;
toggleState = toggleState == ButtonState.Nor mal ?
ButtonState.Pus hed : ButtonState.Nor mal;
this.Invalidate ();
}
ButtonState toggleState = ButtonState.Nor mal;
}
=============== ====
Clay Burch
Syncfusion, Inc.
Peted wrote:
take away its prozac ?
no seriously
I want to drop a button onto a form, then during runtime, when user
clicks the button it stays in the "depressed" image state (with a new
color) then when it is pressed again it pops up to its normal state
and color
and of course i want to execute code on each push down and pop up
any idea how this can be done please.
This seems like check box functionality. Why not to use checkbox
instead with its Appearance property set to Button?
Also a way to make an array of such depresseable buttons, that
function like an array of radio buttons in that only 1 on the panel is
ever selected at any one time
Same thing: radio button has Appearance property which can be set to
Button making it look like push button. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dan V. |
last post by:
I am looking for a great css button navigation tool that can allow me to:
- Ideally use Macromedia DreamWeaver 2004 mx.
- Use CSS buttons that allows the button to stay depressed when I am on a
certain page.
- have a constant top navigation and sub navigation
For example please visit my site at www.officeactivate.com. Though the
method I used works, I am looking for a quicker system, so that one can
change one button and it propagate...
|
by: Jozef |
last post by:
Hi Folks!
I'm wondering if there is a way to make an access button appear pressed in?
I know there was a property or something similar in VB to make a button
appear pressed in. What I'm looking for is not so much for programming,
but for graphics. I have a complete set of buttons already, I was just
hoping there was an easy way to make them all appear depressed without
having to recreate them.
Thanks!
|
by: John |
last post by:
Hi
How can I create a toggle button on a toolbar that would enable/disable
editing on the current form?
Thanks
Regards
|
by: jrhoads23 |
last post by:
Hello,
I am trying to find a way to tell if an .NET windows forms Button
(System.Windows.Forms.Button) is "depressed" (pushed down). For my
application, I can not use a check box control set to button style, I
must use a System.Windows.Forms.Button. I can not find a way to tell
when it is momentaraly pressed.
I tried calling the API SendMessage with the button handle and
BM_GETSTATE to get the state of the button. This will only return...
|
by: Colin McGuire |
last post by:
Hi - this was posted last weekend and unfortunately not resolved. The
solutions that were posted almost worked but after another 5 days of
working on the code everynight, I am not further ahead.
If you do have any ideas I would really like to hear them.
Thanks
Colin
- 0 - 0 - 0 -
I want a glorified popup/context menu on a button that shows only when
| |
by: Ryan |
last post by:
I want to create a button on a Windows form that stays depressed when a user
clicks it (and raises if they click it again). How do I do this?
Thanks,
Ryan
|
by: akineko |
last post by:
Hello everyone,
I'm trying to implement a virtual instrument, which has buttons and
displays, using Tkinter+Pmw.
One of items on the virtual instrument is a round button.
This is imitating a tact switch.
Tkinter has a Button class, which I can assign a button image.
However, when the button is depressed, the rectangle is sunken (rather
than the round button).
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |