I have an autocompletebox that I am trying to remove the border from. Just setting the border to a transparent color or a border thickness of zero isn't good enough, because when the box is moused over, a secondary border appears. The style template for the control is cryptic enough for me that my guesses on changing different parameters have not resulted in border changes.
What do I need to do to disable the border for this control?
Normally, this is due to the FocusVisualElement component in styletemplates for controls.
I can see that the Autocompletebox doesn't have this component, but the Autocompletebox itself is built with more basic controls who do have such an element in their style template.
Try making a style for a textbox without the focusvisualelement (remove it completely from the template) and let the textbox inside the Autocompletebox make use of that template, that should remove the border from the autocompletebox.
So the style contained a control template with the textbox used in the autocomplete user control... I just replaced the style specifically for that textbox to show a transparent border on the mouseover state.
Related
I am using a lot of DatePickers in my C#/WPF application. The people who will be using this app. usually are old and have problems with seeing/reading.
I need to change the pale color of the text to something darker so anyone can read the text in the DatePicker.
How and where can I do that?
I am using Visual Studio 2010 and I see only 4 color properties in Brushes section: Background, BorderBrush, Foreground and OpacityMask.
Or I should be doing this with code, set the Brush with code?
The Foreground property sets the text of the DatePicker in an enabled state. When the DatePicker is disabled, the control template adds a semi-transparent overlay to the control.
You can find the default template here. The overlay is defined in the PART_DisabledVisual Grid. To fix your issue, you can copy the entire ControlTemplate in your code and modify the two Rectangles with Fill="#A5FFFFFF" to Fill="Transparent".
I have set the BackColor property of the form and all controls within it to white, but still some of it has the Control (gray) color (e.g. the context menu of the MenuStrip, the tabs of the TabControl, and the border of the form itself).
Basically I'm trying to make the appearance of my application in flat white.
Is it possible to achieve this in WinForms?
Is there a way to change the "default windows system blue" highlight color in all the controls in a windows form?
Including textbox, datetimepicker and all of them.
Thank you.
Edit
The highlight color is when a user select the text inside the control, normaly it's blue.
Can't change the system highlight color and don't want to.
I'm interested especially on 3 controls: TextBox, DateTimePicker and NumericUpDown.
By all controls I'll assume you mean all of them that would normally have a highlight color... You simply use the SelectionColor property of highlight-able controls.
For example, it can be used like this:
RichTextBox.SelectionColor = Color.Aqua;
This would set the highlight color of the RichTextBox to Aqua. If you however wanted all controls to be highlighted... You would have to override their drawing and force them to redraw while the mouse is clicked and dragged over the area which they reside.
Anyway, I'm having a little difficulty with tab control. When I drag a new tab control onto a form, it appears white, rather than the grey (system colour) I was expecting.
When I look at the properties, its colour is set to web-transparent. Ok, so it should be transparent then (it isn't letting anything behind it show through). Setting the tab control back colour manually back to the system grey kind of works, but the tabs at the top still show as white. I'm assuming I could somehow change their colour as well, but I'm quickly getting into the realms of changing so many values from default, I'm clearly missing something type territory. I've googled every varient of "transparent tab control draws white" as I can, and although I found something to do with windows profiles, this seemed mostly confined to access 2003 using the vb you got access to in access.
I'm looking for any explanation as to:
what I need to do to correctly use transparency with tab controls
what I'm mis-understanding as the purpose of transparency in tab controls
how to easily change all the colours of the appropriate parts of the tab control to not be transparent.
I'm looking at windows forms for an MCTS, so please don't give a "you should use X instead" type answer.
No, getting white is certainly normal. TabControl and TabPage are rendered with theme colors when visual styles are enabled. So that makes the tab page white on machines with the standard Windows theme.
Yes, the default BackColor of Transparent is very unusual. You most certainly will never get actual transparency with that, unless you count seeing the background of the TabControl as transparency. The logic is pretty convoluted, rather than trying to explain it I'll just paste the MSDN explanation:
The default value of the BackColor property is the value of the Control.DefaultBackColor property unless the UseVisualStyleBackColor and Application.RenderWithVisualStyles property values are both true and the Appearance property of the parent TabControl has a value of Normal, in which case the default value of the BackColor property is Transparent. Child controls that you place on the TabPage inherit the BackColor value by default, so this behavior causes the background of the child controls to render with the current visual style.
Changing the value of the BackColor property automatically sets the UseVisualStyleBackColor property to false. If you want the TabPage background to render using visual styles but you want the child controls to inherit a BackColor value that you specify, set the UseVisualStyleBackColor property after you set the BackColor property.
I would like to put a LinkLabel with a transparent background over a TabControl. The tab control has NO tabpage.
As it's not possible to add controls other than TabPages to a TabControl, what I do it add the LinkLabel to the control that contains the TabCOntrol, and then use BringToFront on the LinkLabel. This displays it over the TabControl.
Problem: The LinkLabel displays as transparent (BackColor Property), but instead of showing the TabControl's colour as background, it shows the background colour of it's parent, the control that also contains the TabControl.
From what I understand, this is normal behaviour as a Transparent BackColor means that it'll just take the parent's colour.
Question: Is there any solution to display my LinkLabel with the TabControl's background colour?
Thanks
I may be wrong about this, but I think that if you change the LinkLabel's BackColor property in code (e.g. in your form's Load event, as opposed to just setting it in the designer) to match the color of your TabControl, it will work the way you want it to.
Thanks for your answers. I'm now get what you meant.
Using the tab Control's BackColor won't work, because this property always returns the ColorSystemColors.Control, which is greyish. However, when using visual styles (e.g. XP's default theme), the TabControl's back colour is kind of white. I cannot use white either as the tab control is not pure white, but gradient white...