473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Borderless Button

I want my buttons to look like and behave like the 'Tools' in, for example,
MSPaint. The border of the button is invisible, the image just 'hangs' in
the gray background. When the mouse pointer is moved over the button, the
border shows. Clicking the button first indents the picture and on releasing
the mouse button the selection is visible with a dark border and a lighter
shade of gray as background color.

How can I achieve this?
Nov 20 '06 #1
2 17015
Hey Martijn...
If I understand correctly what you try to achieve:

- Don't use a Button control, but a CheckBox control.

- At design time, set the following properties:
-- Appearance = Button
-- FlatAppearance.BorderColor = whatever you like
-- FlatAppearance.BorderSize = 0
-- FlatAppearance.MouseDownBackColor = whatever you like
-- FlatAppearance.MouseOverBackColor = whatever you like
-- FlatStyle = Flat

At runtime you can catch the MouseEnter and MouseLeave events if you
like, to display a border when necessary. And catch the CheckedChanged
event (for example) to keep the border around when the button is pressed
(checked).
private void checkBox1_CheckedChanged( object sender, EventArgs e )
{
checkBox1.FlatAppearance.BorderSize =
(( sender as CheckBox ).Checked ? 1 : 0);
}

private void checkBox1_MouseEnter( object sender, EventArgs e )
{
checkBox1.FlatAppearance.BorderSize = 1;
}

private void checkBox1_MouseLeave( object sender, EventArgs e )
{
checkBox1.FlatAppearance.BorderSize =
( ( sender as CheckBox ).Checked ? 1 : 0 );
}
Of course, you can finetune this to your liking.

Have fun.

David

Martijn Mulder wrote:
I want my buttons to look like and behave like the 'Tools' in, for example,
MSPaint. The border of the button is invisible, the image just 'hangs' in
the gray background. When the mouse pointer is moved over the button, the
border shows. Clicking the button first indents the picture and on releasing
the mouse button the selection is visible with a dark border and a lighter
shade of gray as background color.

How can I achieve this?

Nov 20 '06 #2
Martijn,

The button FlatStyle property can be set to Popup that has the behaviour you
are after. However there is one small problem that the button shows border
evetn when the mouse is not over it. I haven't try to work around this
problem and I think that it might be possible removing the border. I don't
know though.

The behavior that you described was implemented in the old ToolBar
component. It is still there and you can use it, but you need to install it
manually in the toolbox. I tried it and it works as you want with the small
problem that the 3D border that shows up when the mouse hovers over the
button has rounded corners.
--
Stoitcho Goutsev (100)

"Martijn Mulder" <i@mwrote in message
news:45***********************@news.wanadoo.nl...
>I want my buttons to look like and behave like the 'Tools' in, for example,
MSPaint. The border of the button is invisible, the image just 'hangs' in
the gray background. When the mouse pointer is moved over the button, the
border shows. Clicking the button first indents the picture and on
releasing the mouse button the selection is visible with a dark border and
a lighter shade of gray as background color.

How can I achieve this?

Nov 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nikki | last post by:
Hi, Can anybody help me in solving this problem. I m developing an application in which the main application form is borderless. now i m not able to move the application form with the help of...
5
by: trint | last post by:
I've tried everything... function showRemote() { self.name = ""; // names current window as "main" var windowprops = "border=0,titlebar=0,toolbar=0,location=0,directories=0,status=0, " +...
4
by: David Gouge | last post by:
Hi All, I have a borderless form that i can drag around fine when dragging anywhere on the form by using the following code: protected override void WndProc(ref Message m) { const int...
5
by: ThunderMusic | last post by:
Hi I'm currently developping a skinnable form by using a borderless form (Form.FormBorderStyle=None). Is it the right way to go in the first place? if it is. Assuming that when there is no border...
1
by: SeanR | last post by:
Hi, I wasn't happy with the customisability of the standard Windows form, so I decided to implement my own. Basically what I did was extend a borderless form and add my own borders and caption...
3
by: Rick | last post by:
I know I seen this before but IO cannot find it. How to you drag a borderless form in Vb.net 2005
8
by: James Arnold | last post by:
I currently have a borderless form, which I am subclassing to allow dragging & dropping: Protected Overrides Sub WndProc(ByRef m As Message) Select Case m.Msg Case 132 'Click & Drag Form...
5
by: sierra7 | last post by:
Hi I have been writing Access applications for some years now and have moved away from from the 'Switchboard' type of opening form to using a menubar accross the top of the screen and borderless...
2
by: plevintampabay | last post by:
I have a borderless form in C#. The form has an icon specified in its properties and I also have the same icon specified for the project in the project properties. When I had a border on the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.