473,837 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Align a string on Decimal

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
6 2450
Hi,

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

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

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

Ken
---------------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:2E******** *************** ***********@mic rosoft.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
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 HorizontalAlign ment.right
work for you?

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

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

Ken
---------------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:2E******** *************** ***********@mic rosoft.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
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 HorizontalAlign ment.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****@discuss ions.microsoft. com> wrote in message
news:1C******** *************** ***********@mic rosoft.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 HorizontalAlign ment.right
work for you?

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

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

Ken
---------------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:2E******** *************** ***********@mic rosoft.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
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 HorizontalAlign ment.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****@discuss ions.microsoft. com> wrote in message
news:1C******** *************** ***********@mic rosoft.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 HorizontalAlign ment.right
work for you?

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

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

Ken
---------------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:2E******** *************** ***********@mic rosoft.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
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 HorizontalAlign ment.right as Ken suggests should be exactly what
you want!! You may want to include set the Format property of the
DataGridTextBox Column 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****@discuss ions.microsoft. com> wrote in message
news:61******** *************** ***********@mic rosoft.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 HorizontalAlign ment.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****@discuss ions.microsoft. com> wrote in message
news:1C******** *************** ***********@mic rosoft.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
>> HorizontalAlign ment.right
>> work for you?
>>
>> http://msdn.microsoft.com/library/de...asicprimer.asp
>>
>> http://msdn.microsoft.com/library/de...nmenttopic.asp
>>
>> Ken
>> ---------------------
>> "Dennis" <De****@discuss ions.microsoft. com> wrote in message
>> news:2E******** *************** ***********@mic rosoft.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
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 HorizontalAlign ment.right as Ken suggests should be exactly what
you want!! You may want to include set the Format property of the
DataGridTextBox Column 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****@discuss ions.microsoft. com> wrote in message
news:61******** *************** ***********@mic rosoft.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 HorizontalAlign ment.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****@discuss ions.microsoft. com> wrote in message
news:1C******** *************** ***********@mic rosoft.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
>> HorizontalAlign ment.right
>> work for you?
>>
>> http://msdn.microsoft.com/library/de...asicprimer.asp
>>
>> http://msdn.microsoft.com/library/de...nmenttopic.asp
>>
>> Ken
>> ---------------------
>> "Dennis" <De****@discuss ions.microsoft. com> wrote in message
>> news:2E******** *************** ***********@mic rosoft.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9000
by: Enno Middelberg | last post by:
Hi, I'm sure someone asked this question before, but I can't find the solution on the web or in the groups. I want to print out columns of numbers which are aligned at the decimal point, eg: 123.45
7
5103
by: Stan Brown | last post by:
http://www.acad.sunytccc.edu/instruct/sbrown/stat04/qz05_.htm A table comes near the beginning of the page. I have the <td> of row 1 column 1 styled in line with border-top:none and border-left:none. Yet the top and left borders are still present. I've read the Tables section of the CSS2 spec several times, but obviously there's something I'm not getting. Can someone help? --
7
3030
by: BA | last post by:
Hello, I have a string with a price in: "$14.95" I need to get it into a decimal. So I regex 'd the string and dumped the $. Debug mon shows a clean string "14.95" Then I do a System.Convert.ToDecimal on the clean string and the output
2
2373
by: MS | last post by:
A97 Can you set the format property on text controls to align on the decimal point?
3
3963
by: DaveC | last post by:
Hi.. I have a C exam in a few days.. Looking back at old exams I find a few things we have not been taught / cant remember being taught. Below is a question from last year. My question is how do you align values and define field widths in the printf function? I'm ok with the rest of the question. Thanks DaveC
6
7619
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards, Karthi
5
2003
by: kj | last post by:
I've tried *many* variations of the following: <TABLE> <TR><TD STYLE='text-align: "."; font-family: Courier'>0.12</TD></TR> <TR><TD STYLE='text-align: "."; font-family: Courier'>10.1</TD></TR> <TR><TD STYLE='text-align: "."; font-family: Courier'>123.001</TD></TR> <TR><TD STYLE='text-align: "."; font-family: Courier'>0.02</TD></TR> </TABLE> but they all fail to produce a column of numbers lined up at the
14
4370
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my unformatted data values (as decimals) just fine, so I know there's not a problem with the data retrieval, just the formatting. I have read that this would work: lblPrice.Text = prodRow.ToString("C");
10
1246
by: TC | last post by:
Hey All, I have strings in currency. For example: "$1.29" What is the best way to convert them to decimal formatted like: "1.29" Thanks, TC
0
9843
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10882
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10275
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5670
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5851
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3126
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.