Product: PowerShell Studio 2022 (64 Bit)
Build: v5.8.201
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.18363.0
PowerShell version(s): 5.1.18362.2212
Behavior: Tooltips not showing when First tab from the tabcontrol is removed.
I am writing a GUI where tabs are removed when a certain condition is met.
Situation: At Form Load - When a x user with y rights > remove tabs from the tabcontrol <
Team A: All Tooltips are showing when all tabs are present.
Team B: Need Tab 1 and 3 only to be showed. Tab 2, 4, (5 and 6 empty tabs) are removed. Tooltips are showing.
Team C: Need Tab 2 and 4 only to be showed. Tab 1, 3, 5 and 6 are removed. < Tooltips are not showing except for the ToolStrip with Buttons and the MenuStrip.
Thus I conclude that when the first tab from the tabcontrol is removed > is the cause of this unwanted behavior.
Tooltips not showing when First tab from the tabcontrol is removed.
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
-
- Posts: 8
- Last visit: Fri Jan 26, 2024 2:53 pm
- Has voted: 2 times
-
- Posts: 8
- Last visit: Fri Jan 26, 2024 2:53 pm
- Has voted: 2 times
Re: Tooltips not showing when First tab from the tabcontrol is removed.
I have found a solution to the problem I have encountered.
Replaced this: $TabControl.TabPages.Remove($TabPageX)
To this: $TabControl.TabPages['TabPageX'].Dispose()
Replaced this: $TabControl.TabPages.Remove($TabPageX)
To this: $TabControl.TabPages['TabPageX'].Dispose()
-
- Posts: 8
- Last visit: Fri Jan 26, 2024 2:53 pm
- Has voted: 2 times
Re: Tooltips not showing when First tab from the tabcontrol is removed.
Correction .. bug seems to be somewhere else ..
Re: Tooltips not showing when First tab from the tabcontrol is removed.
[Topic moved by moderator to PowerShell GUIs forum]
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Tooltips not showing when First tab from the tabcontrol is removed.
There is really not enough information to understand what you are seeing. Can you post the simplest PSF that demonstrates the issue.
-
- Posts: 8
- Last visit: Fri Jan 26, 2024 2:53 pm
- Has voted: 2 times
Re: Tooltips not showing when First tab from the tabcontrol is removed.
Thank you but I have found a solution to the problem I have encountered.
It seems that resetting Tooltips on a ListView over and over was buggy with my code..
I wrote this piece of code that, depending on the Profile, the ToolTip is updated.
So, instead of resetting the ToolTip on the Listview, which was the cause of the problem, I reset the Tooltip on the groupbox.
Problem solved.
It seems that resetting Tooltips on a ListView over and over was buggy with my code..
I wrote this piece of code that, depending on the Profile, the ToolTip is updated.
Code: Select all
$UserProfiles = $Reporters.Profile | Group-Object -NoElement
$IsManagerOfToolTip = ($UserProfiles | ForEach-Object { '{0} {1}' -f $_.Count, $_.Name }) -join "`n"
$GroupBoxUserMgmtManageOrReportTo.Text = 'Is Manager Of'
$TooltipMustTotalToolkit.SetToolTip($ListViewUserMgmtOutputManageOrReportTo, $IsManagerOfToolTip)
So, instead of resetting the ToolTip on the Listview, which was the cause of the problem, I reset the Tooltip on the groupbox.
Code: Select all
$TooltipMustTotalToolkit.SetToolTip($GroupBoxUserMgmtManageOrReportTo, $IsManagerOfToolTip)
- Attachments
-
- Gui.JPG (70.56 KiB) Viewed 1179 times
-
- Posts: 8
- Last visit: Fri Jan 26, 2024 2:53 pm
- Has voted: 2 times
Re: Tooltips not showing when First tab from the tabcontrol is removed.
The code that works:
Code: Select all
$ButtonUserMgmtSearch_Click = {
$Global:ADUserInfo = Get-MUSTTotalToolkitADUserInformation -UserName $UserName
if (-not $ADUserInfo -or $ADUserInfo.count -gt 1)
{
$Message = 'Unable to find user {0} !' -f $ComboboxUserMgmt.Text
$MessageBox = Get-MessageBox -Message $Message -Caption 'User Not Found !' -Icon Error -Button OK
if ($MessageBox -eq 'OK')
{
Clear-UserMgmtData
}
}
else
{
$GroupboxUserMgmtInformation.Visible = $true
$DateTimeFormat = @{ Format = 'dd/MM/yyyy HH:mm:ss' }
$Script:DN = $ADUserInfo.distinguishedname
#region User Account Status
#region User Account Enabled/Disabled
if ($ADUserInfo.Enabled)
{
$AccountStatus = 'Enabled'
$LabelUserMgmtOutputAccoutStatus.ForeColor = 'Green'
}
else
{
$AccountStatus = 'Disabled'
$LabelUserMgmtOutputAccoutStatus.ForeColor = 'Red'
}
$LabelUserMgmtOutputAccoutStatus.Text = $AccountStatus
#endregion User Account Enabled/Disabled
#region User Account Locked Out
if ($ADUserInfo.LockedOut)
{
$LabelUserMgmtOutputLockedOut.ForeColor = 'Red'
$ButtonUserMgmtUnlockAccount.Enabled = $true
$ButtonUserMgmtUnlockAccount.PerformClick()
}
else
{
$LabelUserMgmtOutputLockedOut.ForeColor = 'Green'
$TextUnlockAccount = 'User Account is not Locked Out'
$TooltipMustTotalToolkit.SetToolTip($ButtonUserMgmtUnlockAccount, $TextUnlockAccount)
}
$LabelUserMgmtOutputLockedOut.Text = $ADUserInfo.LockedOut
#endregion User Account Locked Out
#endregion User Account Status
#region User Profile
if ($ADUserInfo.IsManager)
{
$GroupBoxUserMgmtManageOrReportTo.Enabled = $true
$GroupBoxUserMgmtManageOrReportTo.Visible = $true
$Reporters = $ADUserInfo.Reporters | Get-MUSTTotalToolkitADUserInformation
$UserProfiles = $Reporters.Profile | Group-Object -NoElement
$IsManagerOfToolTip = ($UserProfiles | ForEach-Object { '{0} {1}' -f $_.Count, $_.Name }) -join "`n"
$GroupBoxUserMgmtManageOrReportTo.Text = 'Is Manager Of'
$TooltipMustTotalToolkit.SetToolTip($GroupBoxUserMgmtManageOrReportTo, $IsManagerOfToolTip)
$ListViewUserMgmtOutputManageOrReportTo.Items.Clear()
$ListViewUserMgmtOutputManageOrReportTo.Refresh()
$ListViewUserMgmtOutputManageOrReportTo.Update()
$Reporters | Sort-Object Profile | ForEach-Object {
Add-ListViewItem -ListviewComputerLogsInfo $ListViewUserMgmtOutputManageOrReportTo -Items $_.Name -SubItems $_.Profile
}
}
if ($ADUserInfo.IsReporter)
{
$GroupBoxUserMgmtManageOrReportTo.Enabled = $true
$GroupBoxUserMgmtManageOrReportTo.Visible = $true
$GroupBoxUserMgmtManageOrReportTo.Text = 'Is Reporter Of'
$Managers = $ADUserInfo.Manager | Get-MUSTTotalToolkitADUserInformation
$TooltipMustTotalToolkit.SetToolTip($GroupBoxUserMgmtManageOrReportTo, '')
$ListViewUserMgmtOutputManageOrReportTo.Items.Clear()
$ListViewUserMgmtOutputManageOrReportTo.Refresh()
$ListViewUserMgmtOutputManageOrReportTo.Update()
$Managers | Sort-Object -Unique | ForEach-Object {
Add-ListViewItem -ListviewComputerLogsInfo $ListViewUserMgmtOutputManageOrReportTo -Items $_.Name -SubItems $_.Profile
}
}
if ($ADUserInfo.Profile -match 'STAFF')
{
$GroupBoxUserMgmtManageOrReportTo.Enabled = $false
$GroupBoxUserMgmtManageOrReportTo.Visible = $false
$GroupBoxUserMgmtManageOrReportTo.Text = ''
$ListViewUserMgmtOutputManageOrReportTo.Items.Clear()
$ListViewUserMgmtOutputManageOrReportTo.Refresh()
$ListViewUserMgmtOutputManageOrReportTo.Update()
}
$LabelUserMgmtOutputLSU.Text = $ADUserInfo.LSU
$LabelUserMgmtOutputLSU.ForeColor = $ADUserInfo.SetScopeColor
$LabelUserMgmtOutputUserProfile.Text = $ADUserInfo.Profile
$LabelUserMgmtOutputUserProfile.ForeColor = $ADUserInfo.SetScopeColor
$LabelUserMgmtOutputOU.Text = $ADUserInfo.OU
$LabelUserMgmtOutputOU.ForeColor = $ADUserInfo.SetScopeColor
#endregion User Profile
#region User Account Description
if ($ADUserInfo.Description.length -gt 31)
{
$Text = '{0} ...' -f $ADUserInfo.Description.Substring(0, 26)
$LabelUserMgmtOutputDescription.Text = $Text
$TooltipMustTotalToolkit.SetToolTip($LabelUserMgmtOutputDescription, $ADUserInfo.Description)
}
else
{
$LabelUserMgmtOutputDescription.Text = $ADUserInfo.Description
$TooltipMustTotalToolkit.SetToolTip($LabelUserMgmtOutputDescription, '')
}
#endregion User Account Description
#region User Account Password Information
$LastBadPasswordAttempt = Get-Date $ADUserInfo.LastBadPasswordAttempt @DateTimeFormat
$AccountExpirationDate = Get-Date $ADUserInfo.AccountExpirationDate @DateTimeFormat
$PasswordInfo = Get-ADUserPasswordInformation $UserName
$Global:PasswordExpirationDate = Get-Date $PasswordInfo.Expiration @DateTimeFormat
$PasswordLastChanged = Get-Date $PasswordInfo.LastChanged @DateTimeFormat
$DaysLeft = $PasswordInfo.DaysLeft
if ($PasswordLastChanged -match '1601')
{
$PasswordLastChanged = 'Never'
$PasswordExpirationDate = 'Never'
$DaysLeft = ''
}
$LabelUserMgmtOutputPWExpiresOn.Text = $PasswordExpirationDate
$LabelUserMgmtOutputPWLastSet.Text = $PasswordLastChanged
$LabelUserMgmtOutputPWBadPWTime.Text = $LastBadPasswordAttempt
$LabelUserMgmtOutputPWBadLogonCount.Text = $ADUserInfo.BadLogonCount
$LabelUserMgmtOutputPWBadPWCount.Text = $ADUserInfo.BadPwdCount
$LabelUserMgmtOutputPWDaysB4Expiration.Text = $DaysLeft
#endregion User Account Password Information
$Offices = $ADUserInfo.Office -join "`n"
$LabelUserMgmtOutputOffice.Text = $Offices
$Created = Get-Date $ADUserInfo.Created @DateTimeFormat
$LabelUserMgmtOutputCreated.Text = $Created
$MailboxCreatedOn = Get-Date $ADUserInfo.MailboxCreatedOn @DateTimeFormat
$LabelUserMgmtOutputMbxCreation.Text = $MailboxCreatedOn
$LabelUserMgmtOutputMBXDB.Text = $ADUserInfo.MailboxDatabaseLink
$LabelUserMgmtOutputDisplayName.Text = $ADUserInfo.DisplayName
$LabelUserMgmtOutputEmployeeNumber.Text = $ADUserInfo.EmployeeNumber
$LabelUserMgmtOutputExpirationDate.Text = $AccountExpirationDate
$LabelUserMgmtOutputUserName.Text = $ADUserInfo.SamAccountName
$LinkLabelUserMgmtOutputEmail.Text = $ADUserInfo.EmailAddress
$LinkLabelUserMgmtOutputPhone.Text = $ADUserInfo.OfficePhone
$ButtonUserMgmtLastLogon.Enabled = $true
$ButtonUserMgmtExtendPassword.Enabled = $true
$ButtonUserMgmtMSTSC.Enabled = $true
$this.Cursor = 'Default'
}
}
Re: Tooltips not showing when First tab from the tabcontrol is removed.
See. The question you posted could never be answered. It is always best to use multiple tooltip controls and to not get fancy with your code. You can use one simple function for all tooltips by detecting the source control.
Watch out for the built-in default tooltip. Use one or the other method but not both.
Again, without the PSF the code is not very useful for us. You should not ask for frum assistance for complex issues without code that can be run. Just a piece of code is not helpful.
Also, just re-looking at your code likely helped you to see the issue. I know that happens to me quite often. Reducing the code to the smallest example often uncovers the problem.
Glad you found a solution.
Watch out for the built-in default tooltip. Use one or the other method but not both.
Again, without the PSF the code is not very useful for us. You should not ask for frum assistance for complex issues without code that can be run. Just a piece of code is not helpful.
Also, just re-looking at your code likely helped you to see the issue. I know that happens to me quite often. Reducing the code to the smallest example often uncovers the problem.
Glad you found a solution.