Page 1 of 1

textbox control and regional settings

Posted: Tue Nov 27, 2018 8:08 am
by ari0k.84
Hi guys,

I'm under Posh Studio up to date version (november 18).
I'm under Windows 7x64 up to date (all framework, visual,c,dot net etc)

I made a little form with some textbox / combobox and textbox validate ip (for IP / Mask / Gateway).
All stuff are working on my W7x64.

I exported it to an .exe file and try it on a W10 1803 x64 : up to date (november 2018 with last .dot net) and It doesn't work as expected because controls textbox IP are showing "," instead of "." (comma instead of dot).
My regional settings in the W10 config is "decimal" = "," and of course, it works if change it to "."

any help, somehting I missed ?
thanks in advance.

PS:I've for instance a premium support for your product until 30 of november, I'm wondering if we renew :) and if i open a ticket...

Re: textbox control and regional settings

Posted: Tue Nov 27, 2018 8:32 am
by jvierra
Windows 10 is using the declared decimal separator. What you are seeing is the normal behavior or Windows.

Re: textbox control and regional settings

Posted: Thu Nov 29, 2018 12:09 am
by ari0k.84
Ok I see. However, why the control textbox Ip isn't properly configure to test OS Version and replace "," by "." ?? Is there a way to do it by properties or something else ? or by the way, is it totally useless in W10 ? Why put this control if it's not properly coded for any OS version ? I don't understand...
Well, much questions uhhh, but i'm so surprised... You agree with the fact that we don't have to change the decimal separator in the OS to put a validating ip textbox in a program ?

Re: textbox control and regional settings

Posted: Thu Nov 29, 2018 7:48 am
by davidc
Try setting the culture of the MaskedTextBox:

$maskedtextboxIP.Culture = 'en-US'

Re: textbox control and regional settings

Posted: Thu Nov 29, 2018 8:54 am
by jvierra
If a "textbox" then the control is not adding the commas or dots. It is in you code. If it is a RichTextBox then you must have set the separator to a comma somehow. If Windows is set to use a comma then this only effects numbers. An IP is not a number it is a string.

Without an example of your code there is no way to guess at what you are asking about. Please post a simple form showing the code that causes this to happen.

Re: textbox control and regional settings

Posted: Mon Dec 03, 2018 3:03 am
by ari0k.84
Ok, first of all, thanks to you both for answering.
I'll attach two screenshots.

I tried $masquedIPtextbox.culture = 'en-us', same thing.

It's not a richtextbox, it's an integrated masquedtextboxip from Sapien.

When i open the form on my computer :> $textbox for ipaddress shows up with . . .
When i open on my w2008r2 or windows 10 :> $textbox for ipaddress shows up with , , ,

And of course, if you enter an ip and hit tab to change textbox, the validate function doesn't work, a red exclamation mark appears. The code is given by Sapien, the function is integrated, so I never touched it or made a mistake. Just using an integrated control & functions...

I modify Regional/Decimal settings to fit (On my own, that's not normal to do that), then it works (of course).

Here's the code from Sapien :

$maskedtextboxIP_Validating=[System.ComponentModel.CancelEventHandler]{
#Event Argument: $_ = [System.ComponentModel.CancelEventArgs]

$IP = $null
try
{
$IP = Get-IPAddressFromMaskedTextBox $this
}
catch
{
$errorprovider1.SetError($this, $_.Exception.Message)
}

$_.Cancel = $IP -eq $null
}

$maskedtextboxIP_Validated={
$errorprovider1.SetError($this, "")

}

function Get-IPAddressFromMaskedTextBox
{
[OutputType([System.Net.IPAddress])]
param(
[Parameter(Mandatory=$true)]
[ValidateNotNull()]
[System.Windows.Forms.MaskedTextBox]$MaskedTextbox)

try{
return [System.Net.IPAddress]::Parse($MaskedTextbox.Text.Replace(" ",""))#Remove Whitespaces
}
catch {
if($_.Exception.InnerException -ne $null)
{
throw $_.Exception.InnerException
}
else
{
throw $_.Exception
}
}

return $null
}

Re: textbox control and regional settings

Posted: Mon Dec 03, 2018 5:45 am
by jvierra
Can you please post a PSF with an example that shows what is happening.

Please note that the top of the page states: "
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file. "

Posting code as text is not helpful.

You can attach your PSF using the "Full Editor" at the bottom of the editor.

From your pictures it certainly looks like you are using a numeric converter which will insert commas. An IP address is a string and not number.

Re: textbox control and regional settings

Posted: Mon Dec 03, 2018 5:57 am
by jvierra
Now that we know it is not a TextBox control but is a MaskedTextbox control I can use it in a form in Windows 10. When I build a form and run it on W10 I see no issue like you are reporting.

Without a copy of your full PSF that shows this issue it is not really possible to see why this might be happening.