C#, BindingNavigator, SplitButton, Ugly dot remaining

364 Views Asked by At

Draw a toolstrip on an empty form. Add a SplitButton on this toolstrip. Will be working as a login in button later on.

On this SplitButton I want to remove the dropdown in the start position. The only thing you can do is to login. Once you have logged in, the dropdown is populated with items like "Change Password", "Update Profile" and so on.

I have tried put the property:

        loginButton.DropDownButtonWidth = 0;

this almost removes the drop down, it is gone, but its a very ugly dot on the right, which seems like to be one pixel left from the drop down corner. See images below:

SplitButton With DropDown

SplitButton Without DropDown

I have tried a lot of other properties to remove the drop down, but no progress. And I cant find anything similar when I google.

I got excellent help fix another problem with the tool strip a few days back, the tool strip had a drawing problem too in its default state. but is removed if you do override a method, see this post:

Toolstrip drawing problem

Does anyone know how I can remove the ugly dot, or remove the drop down some other way?

Full source, one line essentially with the SplitButton named loginButton:

using System;

using System.Windows.Forms;

namespace WindowsFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

    private void Form1_Load(object sender, EventArgs e)
    {
        loginButton.DropDownButtonWidth = 0;
    }
}

}

1

There are 1 best solutions below

1
On

You can use your own renderer to try to achieve that:

private class NoArrowRenderer : ToolStripProfessionalRenderer {
  protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) {
    if (e.Item.GetType() != typeof(ToolStripSplitButton)) {
      base.OnRenderArrow(e);
    }
  }
}

Then apply it to your ToolStrip:

toolStrip1.Renderer = new NoArrowRenderer();