By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,638 Members | 2,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,638 IT Pros & Developers. It's quick & easy.

Align a string on Decimal

P: n/a
I am trying to align a column in DataGrid so the decimal's match up (not
using fixed fonts). Is there anyone who has code for doing this using
StringFormat or something else. Thanks.
--
Dennis in Houston
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi,

Would setting the columns alignment to HorizontalAlignment.right
work for you?

http://msdn.microsoft.com/library/de...asicprimer.asp

http://msdn.microsoft.com/library/de...nmenttopic.asp

Ken
---------------------
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
I am trying to align a column in DataGrid so the decimal's match up (not
using fixed fonts). Is there anyone who has code for doing this using
StringFormat or something else. Thanks.
--
Dennis in Houston
Nov 21 '05 #2

P: n/a
It comes close but really doesn't align the decimal point for Proportional
Fonts, especially numbers like 34.11 and 45.55.

"Ken Tucker [MVP]" wrote:
Hi,

Would setting the columns alignment to HorizontalAlignment.right
work for you?

http://msdn.microsoft.com/library/de...asicprimer.asp

http://msdn.microsoft.com/library/de...nmenttopic.asp

Ken
---------------------
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
I am trying to align a column in DataGrid so the decimal's match up (not
using fixed fonts). Is there anyone who has code for doing this using
StringFormat or something else. Thanks.
--
Dennis in Houston

Nov 21 '05 #3

P: n/a
Dennis,
My understanding is numerics in proportional fonts are *always* the same
width, so a 5 is the same width as a 1, allowing number to be aligned in
columns with no effort!

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want. You may want to include a

34.11
45.55

Can you post sample code or email me a picture where it is not working!

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
It comes close but really doesn't align the decimal point for Proportional
Fonts, especially numbers like 34.11 and 45.55.

"Ken Tucker [MVP]" wrote:
Hi,

Would setting the columns alignment to HorizontalAlignment.right
work for you?

http://msdn.microsoft.com/library/de...asicprimer.asp

http://msdn.microsoft.com/library/de...nmenttopic.asp

Ken
---------------------
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
I am trying to align a column in DataGrid so the decimal's match up (not
using fixed fonts). Is there anyone who has code for doing this using
StringFormat or something else. Thanks.
--
Dennis in Houston

Nov 21 '05 #4

P: n/a
I'm sorry, I meant non-proportional that don't have fixed spacing for the
characters.

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
My understanding is numerics in proportional fonts are *always* the same
width, so a 5 is the same width as a 1, allowing number to be aligned in
columns with no effort!

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want. You may want to include a

34.11
45.55

Can you post sample code or email me a picture where it is not working!

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
It comes close but really doesn't align the decimal point for Proportional
Fonts, especially numbers like 34.11 and 45.55.

"Ken Tucker [MVP]" wrote:
Hi,

Would setting the columns alignment to HorizontalAlignment.right
work for you?

http://msdn.microsoft.com/library/de...asicprimer.asp

http://msdn.microsoft.com/library/de...nmenttopic.asp

Ken
---------------------
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
I am trying to align a column in DataGrid so the decimal's match up (not
using fixed fonts). Is there anyone who has code for doing this using
StringFormat or something else. Thanks.
--
Dennis in Houston


Nov 21 '05 #5

P: n/a
Dennis,
Numerics (0 to 9) in both proportional & non-proportional fonts are always
the same width! (within the same font of course)

My understanding is the reason that numerics are the same widths is so the
digits line up nicely.

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want!! You may want to include set the Format property of the
DataGridTextBoxColumn so that all cells have the same number of decimal
places...

Again can you post sample code or email me a picture where it is not
working!

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
I'm sorry, I meant non-proportional that don't have fixed spacing for the
characters.

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
My understanding is numerics in proportional fonts are *always* the same
width, so a 5 is the same width as a 1, allowing number to be aligned in
columns with no effort!

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want. You may want to include a

34.11
45.55

Can you post sample code or email me a picture where it is not working!

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
> It comes close but really doesn't align the decimal point for
> Proportional
> Fonts, especially numbers like 34.11 and 45.55.
>
> "Ken Tucker [MVP]" wrote:
>
>> Hi,
>>
>> Would setting the columns alignment to
>> HorizontalAlignment.right
>> work for you?
>>
>> http://msdn.microsoft.com/library/de...asicprimer.asp
>>
>> http://msdn.microsoft.com/library/de...nmenttopic.asp
>>
>> Ken
>> ---------------------
>> "Dennis" <De****@discussions.microsoft.com> wrote in message
>> news:2E**********************************@microsof t.com...
>> I am trying to align a column in DataGrid so the decimal's match up
>> (not
>> using fixed fonts). Is there anyone who has code for doing this using
>> StringFormat or something else. Thanks.
>> --
>> Dennis in Houston
>>
>>
>>


Nov 21 '05 #6

P: n/a
You know, I never realized that this was the case and I work with Word and
Excel all the time. I just tried Times New Roman in Word with a right Aligh
tab and you are certainly correct..you've simplified mylife. Thanks a lot.

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
Numerics (0 to 9) in both proportional & non-proportional fonts are always
the same width! (within the same font of course)

My understanding is the reason that numerics are the same widths is so the
digits line up nicely.

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want!! You may want to include set the Format property of the
DataGridTextBoxColumn so that all cells have the same number of decimal
places...

Again can you post sample code or email me a picture where it is not
working!

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
I'm sorry, I meant non-proportional that don't have fixed spacing for the
characters.

"Jay B. Harlow [MVP - Outlook]" wrote:
Dennis,
My understanding is numerics in proportional fonts are *always* the same
width, so a 5 is the same width as a 1, allowing number to be aligned in
columns with no effort!

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want. You may want to include a

34.11
45.55

Can you post sample code or email me a picture where it is not working!

Hope this helps
Jay

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
> It comes close but really doesn't align the decimal point for
> Proportional
> Fonts, especially numbers like 34.11 and 45.55.
>
> "Ken Tucker [MVP]" wrote:
>
>> Hi,
>>
>> Would setting the columns alignment to
>> HorizontalAlignment.right
>> work for you?
>>
>> http://msdn.microsoft.com/library/de...asicprimer.asp
>>
>> http://msdn.microsoft.com/library/de...nmenttopic.asp
>>
>> Ken
>> ---------------------
>> "Dennis" <De****@discussions.microsoft.com> wrote in message
>> news:2E**********************************@microsof t.com...
>> I am trying to align a column in DataGrid so the decimal's match up
>> (not
>> using fixed fonts). Is there anyone who has code for doing this using
>> StringFormat or something else. Thanks.
>> --
>> Dennis in Houston
>>
>>
>>


Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.