Does anybody know why this happens?
I've a TabControl where I insert UserControls but all the elements with white background create a hole in the WinForm and I can see the desktop...
The only way I find is to change Background color of elements but in some Element I've some visual bug.
Related
This question already has answers here:
What is a general solution to creating a transparent control?
(2 answers)
Closed 1 year ago.
I am developing a desktop app using vb.net in Visual Studio 2019. At some point I ask the user to choose the background color of the label they want to create. In the code everything works fine, but when the user chooses a semi-transparent background, say ARGB (116,255,255,000), it skips the alpha part so that I don't get the background transparency I want.
How can I resolve this?
here is how the user chose the label properties
and here is a part of the code that deal with it
Str5 = "116255255000"
Label1.BackColor = Color.FromArgb(Str5.Substring(0, 3), Str5.Substring(3, 3), Str5.Substring(6, 3), Str5.Substring(9, 3))
and here is the result I get
It's working exactly as it is supposed to. Add a BackgroundImage to your form and you'll see that.
Your problem is not that the BackColor is not transparent but, rather, that Windows Forms only supports a fudged form of transparency. When a control is transparent, you don't actually see through it. What actually happens is that an image of it's parent behind it is created and that is shown in the background of the control. It's only the parent itself that is included in this image though, and not any other sibling controls. If you do as I suggested then you'll see that, because you will still see through to the parent where you expect see that other control.
There's no real solution to this issue using WinForms controls. The alternative is to not use a Label but, instead, draw the text and its background colour using GDI+. You can then draw on both the form and the other control(s) and you'll be able to see through to everything you expect.
I am running Visual Studio 2010 Professional (10.0.40219.1 SP1Rel) with no updates showing in Windows Update. When I drop a TextBox control into a Split Container panel, make it Multiline, then Dock in Parent = Fill, it shrinks down to 1 pixel wide and disappears. Of course, at runtime it is invisible.
Is this a bug? Is there a fix? I actually don't need text input - what I want is to display text in a resizable panel, with scroll bars. I could perhaps put code on the events (SizeChanged, SplitterMoved, SplitterMoving...) but that's an ugly solution. Is that the only one?
Apparently I didn't realize I had put a Flow Layout container inside the Split Container panel. This was preventing it from filling the panel.
I'm facing a strange issue. I've add into my VB application a WebBrowser without made any further change on it. And when I run it in order to display a web page like "www.google.com", instead of the white background, I can see the window behind. It's just like the white color is fully transparent. I've try to add a screenshot to this topic but I don't have enough "reputation" yet.
How can I remove this opacity behavior and have the default white background ? Do I need to initialize the webBrowser with white background color ?
Thank you.!
You've most likely accidentally set the TransparencyKey() of the Form to White. Clear that field and see if that fixes the problem.
First Off, I found this extremely useful page on theme brushes:
http://metro.excastle.com/xaml-system-brushes
So Roughly, on startup for WinRT/XAML I am setting my theme brush for a textbox in a stylesheet:
Foreground = TextBoxDisabledForegroundThemeBrush
Background = TextBoxDisabledBackgroundThemeBrush
Which at run time makes the textbox appear as: white border, transparent background and grey text. Which I was hoping it would make it transparent, white border and white text.
On my Tapped event, I change the textbox to:
Foreground = TextBoxButtonPressedForegroundThemeBrush
Background = TextBoxButtonPressedForegroundThemeBrush
Which is supposed to be black background, white text and white border. Which seems right, but the cursor is back and you cannot see it.
First question is, am I doing this right to change my text color? I want to change the textbox so once it is selected it stays a changed color. I think this is correct. But I am not sure if I should be setting Foreground or maybe a Font Style instead?
Unfortunately you can't change caret color so if you want your TextBox editable - you should keep the background white or otherwise light. Otherwise, controlling the look of your control in its various states is best done using VisualStateManager and that is easiest to manipulate using Blend.
I'm trying to make my WP7 app work well on WP8 (by compiling it as a WP8 app).
In my app, I'm changing the PhoneAccentBrush's Color which seems to work fine still, however TextBox's in WP8 now seem to show a border around it when the textbox is in focus (this wasn't happening for me on WP7). This border seems to always use the System's accent color instead of using the changed color like every other control.
Any idea what's going on here and how to change it? The red accent (if that's what the user has chosen) really clashes with my app's colors!
I would call overriding the accent color a hack. I would avoid setting the accent color and create a template for your textBlock.
Blend makes this very easy by allowing you to copy the default template and make changes to it.
Right Click the textBox in the Objects and Timeline pane, then select Edit Template -> Edit Current. Then select the States tab and select the Focused FocusState, then edit the border brush. Save and reuse the template as needed.
I did notice the textBox control template has changed in 8 and now defines the focus state border brush, although it does default to the PhoneAccentBrush.