Remove button border on tab c# winforms

前端 未结 5 1859
深忆病人
深忆病人 2020-12-21 01:29

I have a button on my form that has flat style applied and uses a background image, I have removed all borders from the button, but when I tab onto the button from another c

相关标签:
5条回答
  • 2020-12-21 01:43

    You have to make a new button class using IButtonControl and change NotifyDefault to false:

    base.NotifyDefault(false);
    
    0 讨论(0)
  • 2020-12-21 01:47

    You don't have to create a derived class. You can set the ForeColor to be the same as parent control BackColor. As follows :

    btn1.ForeColor = btn1.Parent.BackColor;
    
    0 讨论(0)
  • 2020-12-21 01:50

    I do not get this border, if I set the BoderSize to 0 in the FlatAppearance section.


    Further investigation shows that this border appears only when the button is the default button. You can create your own button, which does never show this border like this

    public class NoNotifyButton: System.Windows.Forms.Button
    {
        public override void NotifyDefault(bool value)
        {
        }
    }
    

    Note: NotifyDefault remains intentionally empty.

    0 讨论(0)
  • 2020-12-21 01:53

    I managed to get around this by setting the button TabStop property to False and then using this code on the button click event

    private void sendBackTab()
            {
                System.Windows.Forms.SendKeys.SendWait("+{TAB}");
            }
    
    0 讨论(0)
  • 2020-12-21 01:57

    You can do it setting the button property "ForeColor" to transparent

    0 讨论(0)
提交回复
热议问题