Is there a way to reduce the padding between the edges of a button and the text?
I need to put a button on the right side of a textbox with “…” in it. If you click the button, it pops up a list that you can select a value from. I have all of that working, but the button itself takes up a lot of space in the textbox, and most of the space is padding between the edges of the button and the text of the button.
I tried setting the Padding property but it doesn’t appear to have any effect. Reducing the size of the font doesn’t help. I also tried overriding OnPaint, but this also didn’t work.
Also, when focus is set to a TextBox, the border turns yellow and the left border becomes twice as wide, shifting the contents to the right one pixel. This shifts my button to the right one pixel and cuts off its right hand border. Is there any way to override the doubling of the border?
using the tools component is pretty straight forward. Just edit the Tools property of your textbox:
You can set up various parameters like tooltip text, position, icon etc. and it will appear like this:
Then you can just react on the click event and add your custom code like a modal dialog that includes various options etc. :
Hope that helps.
PS: I will add this information also to the docs.
I haven’t tried the Tools collection yet. Is there an example of how to use it online? I found the class reference for ComponentTools in the Docs, but no example code, and unfortunately I can’t figure it out how to use it from the VS autocomplete 🙂
The themes don’t add any padding in the buttons. Make sure that the button you create doesn’t have AutoSize = true, it should be false.
The 3px left border when focused in set in the theme. But its done to work with the inner textfield and when focused it reduces the inner padding in the TextBox with the result of not shifting the content. The problem is probably that you are adding a button as a child of a TextBox docket to the left?
Wisej has a system of tool buttons that can be added to most controls to achieve exactly what you want to achieve without having to create child controls. Did you try the Tools collection of the TextBox? All editable controls and most complex controls support tool buttons.
Please login first to submit.