How Can I change the color of the Text on TabPage?












0














What properties need to be applied to change the forecolor and backcolor of the text on Tabpage?



See Picture:
https://imgur.com/a/Su8aSg7



Here is my Code:



$TabControl_Main = New-Object System.Windows.Forms.TabControl
$TabControl_Main.Location = New-Object System.Drawing.Size(20,550)
$TabControl_Main.Size = New-Object System.Drawing.Size(850,270)
$form_MainForm.Controls.Add($TabControl_Main)

$TabPage1 = New-Object System.Windows.Forms.TabPage
$TabPage1.Location = New-Object System.Drawing.Size(20,550)
$TabPage1.Size = New-Object System.Drawing.Size(850,270)
$TabPage1.Text = "Processes"
$TabControl_Main.Controls.Add($TabPage1)









share|improve this question






















  • $TabControl_Main.BackColor = New-Object System.Drawing.Color("Red") should work as an example
    – TobyU
    Nov 21 '18 at 14:40










  • I want to change the color on each Text on each Tabs :). This code you wrote here cause the following error: "New-Object : A constructor was not found. Cannot find an appropriate constructor for type System.Dra wing.Color."
    – Techno
    Nov 21 '18 at 14:49








  • 1




    $TabControl_Main.BackColor = [System.Drawing.Color]::Red should do it.
    – Theo
    Nov 21 '18 at 15:15










  • Not working. :(
    – Techno
    Nov 23 '18 at 12:41
















0














What properties need to be applied to change the forecolor and backcolor of the text on Tabpage?



See Picture:
https://imgur.com/a/Su8aSg7



Here is my Code:



$TabControl_Main = New-Object System.Windows.Forms.TabControl
$TabControl_Main.Location = New-Object System.Drawing.Size(20,550)
$TabControl_Main.Size = New-Object System.Drawing.Size(850,270)
$form_MainForm.Controls.Add($TabControl_Main)

$TabPage1 = New-Object System.Windows.Forms.TabPage
$TabPage1.Location = New-Object System.Drawing.Size(20,550)
$TabPage1.Size = New-Object System.Drawing.Size(850,270)
$TabPage1.Text = "Processes"
$TabControl_Main.Controls.Add($TabPage1)









share|improve this question






















  • $TabControl_Main.BackColor = New-Object System.Drawing.Color("Red") should work as an example
    – TobyU
    Nov 21 '18 at 14:40










  • I want to change the color on each Text on each Tabs :). This code you wrote here cause the following error: "New-Object : A constructor was not found. Cannot find an appropriate constructor for type System.Dra wing.Color."
    – Techno
    Nov 21 '18 at 14:49








  • 1




    $TabControl_Main.BackColor = [System.Drawing.Color]::Red should do it.
    – Theo
    Nov 21 '18 at 15:15










  • Not working. :(
    – Techno
    Nov 23 '18 at 12:41














0












0








0







What properties need to be applied to change the forecolor and backcolor of the text on Tabpage?



See Picture:
https://imgur.com/a/Su8aSg7



Here is my Code:



$TabControl_Main = New-Object System.Windows.Forms.TabControl
$TabControl_Main.Location = New-Object System.Drawing.Size(20,550)
$TabControl_Main.Size = New-Object System.Drawing.Size(850,270)
$form_MainForm.Controls.Add($TabControl_Main)

$TabPage1 = New-Object System.Windows.Forms.TabPage
$TabPage1.Location = New-Object System.Drawing.Size(20,550)
$TabPage1.Size = New-Object System.Drawing.Size(850,270)
$TabPage1.Text = "Processes"
$TabControl_Main.Controls.Add($TabPage1)









share|improve this question













What properties need to be applied to change the forecolor and backcolor of the text on Tabpage?



See Picture:
https://imgur.com/a/Su8aSg7



Here is my Code:



$TabControl_Main = New-Object System.Windows.Forms.TabControl
$TabControl_Main.Location = New-Object System.Drawing.Size(20,550)
$TabControl_Main.Size = New-Object System.Drawing.Size(850,270)
$form_MainForm.Controls.Add($TabControl_Main)

$TabPage1 = New-Object System.Windows.Forms.TabPage
$TabPage1.Location = New-Object System.Drawing.Size(20,550)
$TabPage1.Size = New-Object System.Drawing.Size(850,270)
$TabPage1.Text = "Processes"
$TabControl_Main.Controls.Add($TabPage1)






winforms powershell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 14:33









Techno

33




33












  • $TabControl_Main.BackColor = New-Object System.Drawing.Color("Red") should work as an example
    – TobyU
    Nov 21 '18 at 14:40










  • I want to change the color on each Text on each Tabs :). This code you wrote here cause the following error: "New-Object : A constructor was not found. Cannot find an appropriate constructor for type System.Dra wing.Color."
    – Techno
    Nov 21 '18 at 14:49








  • 1




    $TabControl_Main.BackColor = [System.Drawing.Color]::Red should do it.
    – Theo
    Nov 21 '18 at 15:15










  • Not working. :(
    – Techno
    Nov 23 '18 at 12:41


















  • $TabControl_Main.BackColor = New-Object System.Drawing.Color("Red") should work as an example
    – TobyU
    Nov 21 '18 at 14:40










  • I want to change the color on each Text on each Tabs :). This code you wrote here cause the following error: "New-Object : A constructor was not found. Cannot find an appropriate constructor for type System.Dra wing.Color."
    – Techno
    Nov 21 '18 at 14:49








  • 1




    $TabControl_Main.BackColor = [System.Drawing.Color]::Red should do it.
    – Theo
    Nov 21 '18 at 15:15










  • Not working. :(
    – Techno
    Nov 23 '18 at 12:41
















$TabControl_Main.BackColor = New-Object System.Drawing.Color("Red") should work as an example
– TobyU
Nov 21 '18 at 14:40




$TabControl_Main.BackColor = New-Object System.Drawing.Color("Red") should work as an example
– TobyU
Nov 21 '18 at 14:40












I want to change the color on each Text on each Tabs :). This code you wrote here cause the following error: "New-Object : A constructor was not found. Cannot find an appropriate constructor for type System.Dra wing.Color."
– Techno
Nov 21 '18 at 14:49






I want to change the color on each Text on each Tabs :). This code you wrote here cause the following error: "New-Object : A constructor was not found. Cannot find an appropriate constructor for type System.Dra wing.Color."
– Techno
Nov 21 '18 at 14:49






1




1




$TabControl_Main.BackColor = [System.Drawing.Color]::Red should do it.
– Theo
Nov 21 '18 at 15:15




$TabControl_Main.BackColor = [System.Drawing.Color]::Red should do it.
– Theo
Nov 21 '18 at 15:15












Not working. :(
– Techno
Nov 23 '18 at 12:41




Not working. :(
– Techno
Nov 23 '18 at 12:41












1 Answer
1






active

oldest

votes


















0














You have to create an event and draw the area. Here is some code based on this example in c#, credits @Fun Mun Pieng.



# assign a color for each tab
$PageColor = @{0 = "lightgreen";
1 = "yellow";
2 = "lightblue"}

# define the event
$tabControl_Drawing = {
param([object]$Sender, [System.EventArgs]$e)

$Background = new-object Drawing.SolidBrush $PageColor[$e.Index]
$Foreground = new-object Drawing.SolidBrush black

$tabGraphics = $e.Graphics
$tabBounds = $e.Bounds
$tabGraphics.FillRectangle($Background,$tabBounds)
$tabTextSize = $tabGraphics.MeasureString($sender.TabPages[$e.Index].text, $e.Font)

$tabGraphics.DrawString($Sender.TabPages[$e.Index].Text,$e.Font,$Foreground,$tabBounds.Left + ($tabBounds.Width - $tabTextSize.Width) / 2,$tabBounds.Top + ($tabBounds.Height -$tabTextSize.Height) / 2 +1)
$e.DrawFocusRectangle()
}
# add the event
$TabControl_Main.add_DrawItem($tabControl_Drawing)


A little easier to use is HotTrack:



$TabControl_Main.HotTrack = $true


You will see the effect when you execute your script with powershell instead of powershell ISE.



BackColor does nothing. To use the words of MSDN:




BackColor > This member is not meaningful for this control.




edit: added the code.






share|improve this answer























  • I tested this, I can't see changes : I want this in Powershell: stackoverflow.com/questions/30039627/…
    – Techno
    Nov 23 '18 at 12:44












  • @Techno added some code that should do what you want. For HotTrack it's important to execute your script with Powershell or copy it into a powershell seassion. In ISE you wont see the changes.
    – T-Me
    Nov 26 '18 at 11:45











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414383%2fhow-can-i-change-the-color-of-the-text-on-tabpage%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You have to create an event and draw the area. Here is some code based on this example in c#, credits @Fun Mun Pieng.



# assign a color for each tab
$PageColor = @{0 = "lightgreen";
1 = "yellow";
2 = "lightblue"}

# define the event
$tabControl_Drawing = {
param([object]$Sender, [System.EventArgs]$e)

$Background = new-object Drawing.SolidBrush $PageColor[$e.Index]
$Foreground = new-object Drawing.SolidBrush black

$tabGraphics = $e.Graphics
$tabBounds = $e.Bounds
$tabGraphics.FillRectangle($Background,$tabBounds)
$tabTextSize = $tabGraphics.MeasureString($sender.TabPages[$e.Index].text, $e.Font)

$tabGraphics.DrawString($Sender.TabPages[$e.Index].Text,$e.Font,$Foreground,$tabBounds.Left + ($tabBounds.Width - $tabTextSize.Width) / 2,$tabBounds.Top + ($tabBounds.Height -$tabTextSize.Height) / 2 +1)
$e.DrawFocusRectangle()
}
# add the event
$TabControl_Main.add_DrawItem($tabControl_Drawing)


A little easier to use is HotTrack:



$TabControl_Main.HotTrack = $true


You will see the effect when you execute your script with powershell instead of powershell ISE.



BackColor does nothing. To use the words of MSDN:




BackColor > This member is not meaningful for this control.




edit: added the code.






share|improve this answer























  • I tested this, I can't see changes : I want this in Powershell: stackoverflow.com/questions/30039627/…
    – Techno
    Nov 23 '18 at 12:44












  • @Techno added some code that should do what you want. For HotTrack it's important to execute your script with Powershell or copy it into a powershell seassion. In ISE you wont see the changes.
    – T-Me
    Nov 26 '18 at 11:45
















0














You have to create an event and draw the area. Here is some code based on this example in c#, credits @Fun Mun Pieng.



# assign a color for each tab
$PageColor = @{0 = "lightgreen";
1 = "yellow";
2 = "lightblue"}

# define the event
$tabControl_Drawing = {
param([object]$Sender, [System.EventArgs]$e)

$Background = new-object Drawing.SolidBrush $PageColor[$e.Index]
$Foreground = new-object Drawing.SolidBrush black

$tabGraphics = $e.Graphics
$tabBounds = $e.Bounds
$tabGraphics.FillRectangle($Background,$tabBounds)
$tabTextSize = $tabGraphics.MeasureString($sender.TabPages[$e.Index].text, $e.Font)

$tabGraphics.DrawString($Sender.TabPages[$e.Index].Text,$e.Font,$Foreground,$tabBounds.Left + ($tabBounds.Width - $tabTextSize.Width) / 2,$tabBounds.Top + ($tabBounds.Height -$tabTextSize.Height) / 2 +1)
$e.DrawFocusRectangle()
}
# add the event
$TabControl_Main.add_DrawItem($tabControl_Drawing)


A little easier to use is HotTrack:



$TabControl_Main.HotTrack = $true


You will see the effect when you execute your script with powershell instead of powershell ISE.



BackColor does nothing. To use the words of MSDN:




BackColor > This member is not meaningful for this control.




edit: added the code.






share|improve this answer























  • I tested this, I can't see changes : I want this in Powershell: stackoverflow.com/questions/30039627/…
    – Techno
    Nov 23 '18 at 12:44












  • @Techno added some code that should do what you want. For HotTrack it's important to execute your script with Powershell or copy it into a powershell seassion. In ISE you wont see the changes.
    – T-Me
    Nov 26 '18 at 11:45














0












0








0






You have to create an event and draw the area. Here is some code based on this example in c#, credits @Fun Mun Pieng.



# assign a color for each tab
$PageColor = @{0 = "lightgreen";
1 = "yellow";
2 = "lightblue"}

# define the event
$tabControl_Drawing = {
param([object]$Sender, [System.EventArgs]$e)

$Background = new-object Drawing.SolidBrush $PageColor[$e.Index]
$Foreground = new-object Drawing.SolidBrush black

$tabGraphics = $e.Graphics
$tabBounds = $e.Bounds
$tabGraphics.FillRectangle($Background,$tabBounds)
$tabTextSize = $tabGraphics.MeasureString($sender.TabPages[$e.Index].text, $e.Font)

$tabGraphics.DrawString($Sender.TabPages[$e.Index].Text,$e.Font,$Foreground,$tabBounds.Left + ($tabBounds.Width - $tabTextSize.Width) / 2,$tabBounds.Top + ($tabBounds.Height -$tabTextSize.Height) / 2 +1)
$e.DrawFocusRectangle()
}
# add the event
$TabControl_Main.add_DrawItem($tabControl_Drawing)


A little easier to use is HotTrack:



$TabControl_Main.HotTrack = $true


You will see the effect when you execute your script with powershell instead of powershell ISE.



BackColor does nothing. To use the words of MSDN:




BackColor > This member is not meaningful for this control.




edit: added the code.






share|improve this answer














You have to create an event and draw the area. Here is some code based on this example in c#, credits @Fun Mun Pieng.



# assign a color for each tab
$PageColor = @{0 = "lightgreen";
1 = "yellow";
2 = "lightblue"}

# define the event
$tabControl_Drawing = {
param([object]$Sender, [System.EventArgs]$e)

$Background = new-object Drawing.SolidBrush $PageColor[$e.Index]
$Foreground = new-object Drawing.SolidBrush black

$tabGraphics = $e.Graphics
$tabBounds = $e.Bounds
$tabGraphics.FillRectangle($Background,$tabBounds)
$tabTextSize = $tabGraphics.MeasureString($sender.TabPages[$e.Index].text, $e.Font)

$tabGraphics.DrawString($Sender.TabPages[$e.Index].Text,$e.Font,$Foreground,$tabBounds.Left + ($tabBounds.Width - $tabTextSize.Width) / 2,$tabBounds.Top + ($tabBounds.Height -$tabTextSize.Height) / 2 +1)
$e.DrawFocusRectangle()
}
# add the event
$TabControl_Main.add_DrawItem($tabControl_Drawing)


A little easier to use is HotTrack:



$TabControl_Main.HotTrack = $true


You will see the effect when you execute your script with powershell instead of powershell ISE.



BackColor does nothing. To use the words of MSDN:




BackColor > This member is not meaningful for this control.




edit: added the code.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 26 '18 at 11:35

























answered Nov 22 '18 at 15:01









T-Me

1157




1157












  • I tested this, I can't see changes : I want this in Powershell: stackoverflow.com/questions/30039627/…
    – Techno
    Nov 23 '18 at 12:44












  • @Techno added some code that should do what you want. For HotTrack it's important to execute your script with Powershell or copy it into a powershell seassion. In ISE you wont see the changes.
    – T-Me
    Nov 26 '18 at 11:45


















  • I tested this, I can't see changes : I want this in Powershell: stackoverflow.com/questions/30039627/…
    – Techno
    Nov 23 '18 at 12:44












  • @Techno added some code that should do what you want. For HotTrack it's important to execute your script with Powershell or copy it into a powershell seassion. In ISE you wont see the changes.
    – T-Me
    Nov 26 '18 at 11:45
















I tested this, I can't see changes : I want this in Powershell: stackoverflow.com/questions/30039627/…
– Techno
Nov 23 '18 at 12:44






I tested this, I can't see changes : I want this in Powershell: stackoverflow.com/questions/30039627/…
– Techno
Nov 23 '18 at 12:44














@Techno added some code that should do what you want. For HotTrack it's important to execute your script with Powershell or copy it into a powershell seassion. In ISE you wont see the changes.
– T-Me
Nov 26 '18 at 11:45




@Techno added some code that should do what you want. For HotTrack it's important to execute your script with Powershell or copy it into a powershell seassion. In ISE you wont see the changes.
– T-Me
Nov 26 '18 at 11:45


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414383%2fhow-can-i-change-the-color-of-the-text-on-tabpage%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Feedback on college project

Futebolista

Albești (Vaslui)