2

I am working on a project that is using a Victorian look and feel: enter image description here

The problem that I'm having is with the AcceptButton (or OK or default acceptance) button. Obviously, I can make the button transparent and I can set the borders to 0 width. The problem is that when this particular button (notice how the Cancel button doesn't have this problem) is marked as the AcceptButton it automatically draws a border around it.

Is there a property that I can set that will override this?

Thanks!

LarsTech
  • 80,625
  • 14
  • 153
  • 225
zetar
  • 1,225
  • 2
  • 20
  • 45
  • When in designer that is indicating the accept button. If you run the app you should not see this unless that button, even the cancel, has focus. Unless you have tab stop set to false. – Brian from state farm Jun 03 '16 at 17:09
  • What you see is not a button border but the focus indiactor. Do you really want to hide the focus from the user? Bad ui design, imo. You stil can do it by simple owner-drawing the button. – TaW Jun 03 '16 at 17:51
  • I'm seeing the border even in the app when i call this dialog box.I've disabled the mouse over and mouse down highlighting, too. Yes, technically, it's not good UI design, but this is a game and, traditionally, you get a bit more latitude in game UI. – zetar Jun 03 '16 at 17:54
  • You did choose FlatStyle.Flat, right? I only see it if the focus is on the button; by owner-drawing it the focuis rectangle is gone, unless I draw it.. You are of course quite right wrt games, but I still hate it if I don't see the focus. But using a color for this is fine as well.. – TaW Jun 03 '16 at 17:56
  • Yes, I've chosen FlatStyle.Flat. The border appears when I set as the AcceptButton in the form itself. – zetar Jun 03 '16 at 17:57

2 Answers2

3

Subclass the Button and overide the ShowFocusCues property so that it returns False:

public class MyButton : Button
{

    protected override bool ShowFocusCues
    {
        get
        {
            return false;
        }
    }
}
Mariusz Jamro
  • 30,615
  • 24
  • 120
  • 162
1

Got it. Here's the solution:

OKButton.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255); //transparent
zetar
  • 1,225
  • 2
  • 20
  • 45