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.
hrlarsen
Posts: 27
Joined: Tue Jul 24, 2018 8:36 pm

Style Windows.Forms.Button

Post by hrlarsen » Tue Jul 31, 2018 5:03 am

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.

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Style Windows.Forms.Button

Post by jvierra » Tue Jul 31, 2018 5:19 am

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: 27
Joined: Tue Jul 24, 2018 8:36 pm

Re: Style Windows.Forms.Button

Post by hrlarsen » Tue Jul 31, 2018 9:54 am

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)

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Style Windows.Forms.Button

Post by jvierra » Tue Jul 31, 2018 9:59 am

Windows Forms does not support those options. They are only available in WPF.

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Style Windows.Forms.Button

Post by jvierra » Tue Jul 31, 2018 10:16 am

See the following thread: viewtopic.php?t=11776

hrlarsen
Posts: 27
Joined: Tue Jul 24, 2018 8:36 pm

Re: Style Windows.Forms.Button

Post by hrlarsen » Tue Jul 31, 2018 11:34 am

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.

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Style Windows.Forms.Button

Post by jvierra » Tue Jul 31, 2018 11:48 am

Its in the toolbox on the custom control sets tab. Just follow the instructions in the link.

hrlarsen
Posts: 27
Joined: Tue Jul 24, 2018 8:36 pm

Re: Style Windows.Forms.Button

Post by hrlarsen » Wed Aug 01, 2018 2:34 am

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.

User avatar
jvierra
Posts: 13392
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Style Windows.Forms.Button

Post by jvierra » Wed Aug 01, 2018 8:29 am

I cannot understand what you are asking. It is somewhat vague and a bit convoluted.
What have you tried?

hrlarsen
Posts: 27
Joined: Tue Jul 24, 2018 8:36 pm

Re: Style Windows.Forms.Button

Post by hrlarsen » Wed Aug 01, 2018 9:49 am

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.

Locked