Unable to change Panel Visibility - vb.net

I'm having a panel inside another panel. Now I need to alter inner panel's visibility based on certain condition. But I'm unable to change. It always remains to False. Here is the code I'm trying to:
PnlTagFolders.Visible = True 'Always remains False.
PnlTagFolders.BringToFront()
Here is the screenshot for reference:

You can't make a Panel visible if the parent Panel isn't visible. So make sure the parent Panel is visible (.Visible = True).
true if the control and all its child controls are displayed; otherwise, false. The default is true.
source: Microsoft Docs
See the following:
ChildPanel.Visible = False
ParentPanel.Visible = False
ChildPanel.Visible = True
Debug.Print(ChildPanel.Visible) 'False
Another example:
ChildPanel.Visible = False
ParentPanel.Visible = True
ChildPanel.Visible = True
Debug.Print(ChildPanel.Visible) 'True

Related

Failing to select or set focus to a custom control

I have the following code to select a custom control. But it does not want to set the active control to 'uPnlEntryOptions'. I have tried using control.select as well, same result. I have also tried
ActiveControl = uPnlEntryOptions
Code
uPnlEntryOptions.Visible = True
uPnlEntryOptions.Refresh()
uPnlEntryOptions.Select()
uPnlEntryOptions.Focus()
Debug.Print(CStr(uPnlEntryOptions.Focused))
Debug.Print(CStr(uPnlEntryOptions.CanFocus))
Output
False
True
The Focused property is true only if the control has the focus, not a sub-control.
Calling Select (or Focus?) on a UserControl will select the first child control. Afterwards the UserControl.ContainsFocus = True since the focus is WITHIN the UserControl, but the UserControl.Focused = False, since the UserControl itself isn't the focused control.

groupbox not becoming visible

I'm having a problem getting a second GroupBox visible, this is my code
Me.grpCallerDetails.Location = New Point(x:=0, y:=2000)
Me.grpCallerDetails.Visible = False
Me.grpCallDuration.Location = New Point(x:=0, y:=0)
Me.grpCallDuration.BringToFront()
Me.grpCallDuration.Visible = True
Me.Refresh()
the grpCallDuration.Visible property remains False even after setting the property to True.
Initially the settings are:
Me.grpCallerDetails.Location = New Point(x:=0, y:=0)
Me.grpCallerDetails.Visible = True
Me.grpCallDuration.Location = New Point(x:=2000, y:=0)
Me.grpCallDuration.Visible = False
I'm moving the location of the group boxes around so that they don't overlap, but nothing, so far is working.
What is going on?
OK, I solved it.
The problem was grpCallerDetails was Docked Fill, and grpCallDuration remained as a child of that GroupBox no matter what I did.
I just changed the Dock to None and moved grpCallDuration out on its own...

RadioButtons Highlighting Incorrectly

On my form, I have 4 RadioButtons, each with its appearance set to Button. In my program, I change each of these RadioButton's ForeColour, BackColour and AutoCheck status, as below:
ARadioButton.AutoCheck = False
ARadioButton.BackColor = Color.FromKnownColor(KnownColor.ControlLightLight)
ARadioButton.ForeColor = Color.FromKnownColor(KnownColor.ControlDark)
However, later on, I reset these properties back to default:
ARadioButton.AutoCheck = True
ARadioButton.BackColor = DefaultBackColor
ARadioButton.ForeColor = DefaultForeColor
My issue is that instead of the entire button being highlighted, only the outside is, as shown in the images below.
Originally:
After changes are made and RadioButtons reset to default using code above:
I know this may seem trivial, but I would like the entire RadioButton to be highlighted when the user clicks on the RadioButton, not just the outside.
Is there a way I could somehow reset this?
Try setting the BackColor property to Color.Transparent

How to get scrollbar in Panel in VB.Net?

I am developing a Windows Application in VB.Net. In that, there is one case where there is one form, and in that form there is a Panel, and within the Panel there is a rich text box.
So my requirement is to get a scrollbar in the Panel. So when the user does scroll on the panel, the rich text box can scroll accordingly like MS Office functionality..
Can any one give me an idea how to do it?
Set Panel.AutoScroll = True and scrollbars will automatically appear whenever any controls in the panel fall outside its boundaries.
Set the .Dock property to FILL and the .WordWrap property to FALSE for the richtextbox.
Also set the Panel's .Dock property to FILL.
In order to use panel autoscroll property I do that:
panel.AutoScroll = true
panel.VerticalScroll.Visible = False or panel.HorizontalScroll.Visible = False
In order to know the dimensions of the scroolbars use
SystemInformation.HorizontalScrollBarHeight
SystemInformation.VerticalScrollBarWidth
So you can change the dimension of the panel when the scroolbar is shown.

creating a static vb.net "app" that consist of a single picture

I need to create a vb.net program that consists of a unmovable, always on top bitmap, with no menu bar or anything, and does not show up in the task bar as program.
It needs to always start in the same place.
Essentially I need to mask a part of the screen by using a bitmap that blends into the scenery.
I am not sure which properties I need to tweak to achieve all of this.
Just to try changing the properties until you get the right result, but the below is probably sort of what you're looking for.
StartPosition = Manual
ShowInTaskBar = False
SizeGripStyle = Hide
TopMost = True
ControlBox = False
FormBorderStyle = None
Location = X, Y 'wherever it should be