Support Forums

format for Textbox and DatagridView

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.
User avatar
jramon.r@tv3.cat
Posts: 15
Joined: Mon Jan 19, 2015 2:32 am

format for Textbox and DatagridView

Postby jramon.r@tv3.cat » Fri Jan 29, 2016 12:21 am

My Powershell Studio runs in a Windows 2008 R2, 64 bits.

I'm trying to show data from an access table in a DataGridView. I'd like to show number data with thousand punctuation. I found the property CellStyleBuilder and here I changed the Format to Numeric. The result is that it shows one row good with the appropiate punctuation and one without the punctuation, it alternates one good and one bad. What's happening?

In a similar situation I show the same data in a TextBox, and here I don't Know how I can change the format to Numeric with the thousand punctuation, or if it'd be better use another control.

Thank you
User avatar
jvierra
Posts: 9693
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: format for Textbox and DatagridView

Postby jvierra » Fri Jan 29, 2016 12:32 am

You need to post an example PSF file showing the issue.

For a textbox that is formatted you need to use the MaskedTextBox control.
User avatar
jvierra
Posts: 9693
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: format for Textbox and DatagridView

Postby jvierra » Fri Jan 29, 2016 12:49 am

Take a look at this demo. It shows how to format the numbers in a column.
Attachments
Demo-DGVFrmatting.psf
(15.98 KiB) Downloaded 118 times
User avatar
jramon.r@tv3.cat
Posts: 15
Joined: Mon Jan 19, 2015 2:32 am

Re: format for Textbox and DatagridView

Postby jramon.r@tv3.cat » Fri Jan 29, 2016 4:31 am

Finally I've found the solution. In the DataGridView I was modifying the property AlternatingRowsDefaultCellStyle, this is the cause it showed me just odd rows good.

With the MaskedTextBox I don't understand it very well, how can I show thousands, because sometimes it can be a number like 1.000 but sometimes it can be 10.000, so the thousand punctuation is not always in the same place, do you know how can I do it?

Thank you
User avatar
jvierra
Posts: 9693
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: format for Textbox and DatagridView

Postby jvierra » Fri Jan 29, 2016 8:24 am

There is a pre-defined mask for numeric display.

'{0:N2}' -f 1Mb

Select the N2 mask.

Unfortunately you will have to programmatically set the display as there is no mask for that in standard forms.
User avatar
jramon.r@tv3.cat
Posts: 15
Joined: Mon Jan 19, 2015 2:32 am

Re: format for Textbox and DatagridView

Postby jramon.r@tv3.cat » Mon Feb 01, 2016 12:45 am

Ok thanks.

Return to “Windows PowerShell”

Who is online

Users browsing this forum: No registered users and 3 guests