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?