Style Windows.Forms.Button

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Style Windows.Forms.Button

Post by hrlarsen »

How many ways can I Style a Button
New-Object System.Windows.Forms.Button

Some off the things I like to now code to is how to:

-Shadow button
-Border Size button
-Border Radius
-Border Color button
-Border remove do not show on button
-Border remove hyperlink blue color around button
And text style button

If I am missing anything please provide it.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Style Windows.Forms.Button

Post by jvierra »

Whenever you need to find what properties are available and how to use them just look it up:

https://msdn.microsoft.com/en-us/librar ... .110).aspx

You can right click on the control in the toolbox and there will be a link to the online documentation..
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: Style Windows.Forms.Button

Post by hrlarsen »

Thanks for the link I have found out a couble off things until now about button

How to remove button border (around the button)
How to Size border (around button)
How to disable a button (after click)
How to size and location button
How to color Front and Back button
How to remove Hyperlink color (around button)


But next I am missing more things like how to
Set Shadow on a button
Set Border Radius (so it can be round)
Set Border Color alone (whit out mixing front and back color button)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Style Windows.Forms.Button

Post by jvierra »

Windows Forms does not support those options. They are only available in WPF.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Style Windows.Forms.Button

Post by jvierra »

See the following thread: viewtopic.php?t=11776
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: Style Windows.Forms.Button

Post by hrlarsen »

I have never heard off WPFControl and what that is?
But what I can see, is that you are forced to find a way to connect Powershell whit XAML script language.
And then drop Powershell and do all button design in XAML if that is possible.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Style Windows.Forms.Button

Post by jvierra »

Its in the toolbox on the custom control sets tab. Just follow the instructions in the link.
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: Style Windows.Forms.Button

Post by hrlarsen »

Thanks I have just found it under Toolbox
"ElementHost-WPF Control"


About the Toolbox.
is it possible to have a centeret content box in a form.
And 3 standard button´s to the left outside the Window.

Like this:
Button 1 (mainBox Standard Default show content Window when form opens)
Button 2 (mainBox content to button 2)
Button 3 (mainBox content to button 3)
Clear the mainBox content window when click on the 3 buttons and show the others content in the same center window box.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Style Windows.Forms.Button

Post by jvierra »

I cannot understand what you are asking. It is somewhat vague and a bit convoluted.
What have you tried?
hrlarsen
Posts: 31
Last visit: Sun Dec 18, 2022 1:47 pm

Re: Style Windows.Forms.Button

Post by hrlarsen »

okay let me try this way.


#You have a Form
$Form1 = New-Object System.Windows.Forms.Form
$Form1.Text = "Form"
$Form1.Size = New-Object System.Drawing.Size(600,450)
$Form1.StartPosition = "CenterScreen"
$Form1.Controls.Add($Form1)

#Then you have a Textbox where you can input content
$textbox1 = New-Object System.Windows.Forms.TextBox
$textbox1.Location = New-Object System.Drawing.Size(80,72)
$textbox1.Size = New-Object System.Drawing.Size(135,20)
$textbox1.Text = "TextBox"
$Form1.Controls.Add($textbox1)

Now you have a Form and Textbox.

Now we need 3 buttons like this.
Button 1
Button 2
Button 3


First Button
$Button1 = New-Object System.Windows.Forms.Button
$Button1.Location = New-Object System.Drawing.Size(0,100)
$Button1.Size = New-Object System.Drawing.Size(150,23)
$Button1.Text = "Button"
$Button1.ForeColor = "Blue"
$Form1.Controls.Add($Form1)

And Button 2-3 after.

Now we need the 3 buttons to do the following.
-------------------------------------------------------------------
Click Button 1 action
--------------------
Clear Textbox
Show text content for button 1 in Textbox

Click Button 2 action
--------------------
Clear Textbox
Show text content for button 2 in Textbox

Click Button 3 action
--------------------
Clear Textbox
Show text content for button 3 in Textbox

And as standard Textbox content is showed for button 1 when then Form open.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked