Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to move right justified numbers to the left in a grid?

Status
Not open for further replies.

dsandlin

Programmer
Jul 11, 2003
56
CR
I am trying to move right-justified numeric data in a grid left a couple of spaces to get some white space instead of having the numbers jammed up against the line of the column separator.

The answer seemed obvious: put a format into the inputmask property of the column. I found that entering "9999 " in the inputmask worked great, except that it printed the quote marks. When I removed the quote marks, the display ignored my trailing spaces and jammed the numbers against the line again. I tried 9999AA and it printed the A's. Apparently, trailing spaces are ignored, but any other characters are simply printed out.

It seems that the column inputmask overrides the textbox inputmask and the column alignment overrides the textbox alignment, just from trial and error.

I need for the values to stay numeric, if possible. I assume that I could use the old faithful TRANSFORM() with a format string and print characters, but I hope to find a better way.

Can anyone suggest a simple solution? Thanks in advance!

--Dick (a sometimes frustrated C++ veteran) [bigears]
 
First, there's a quirk with the way grids work that you need to know in order to understand what's going on.

Unless you've set the column's Sparse property to .F., you don't actually see the textbox in the column until it receives focus. So if you set an InputMask for the column, you'll see it when the cell doesn't have focus, but it will use the InputMask for the textbox when the cell has focus.

Now, as for your problem, you may want to try setting the column's Alignment property to Middle Center. The problem with that is that the numbers won't be aligned.



-BP
 
BP,

Thanks a lot! I had forgotten about that strange Sparse property that I didn't understand very well. You have made it clearer to me how it works. This interacts with a strangeness of the grid to produce a totally weird result. Apparently, the problem of the ignored trailing spaces (if you don't use quotes) in the inputmask is unique to the grid. If you can get the textbox to be the CurrentControl, it works fine without the quotes. Grids seem to be a thing apart. I love the power of them, but they are tricky, since a lot of the details don't seem to work like other controls.

The only gottcha seems to be that now the text is pushed higher on the line. The textbox doesn't have the nice Top, Middle, Bottom choice on its alignment property. It seems that by turning OFF Sparse, I am now unable to control this vertical placement, which defaults to Top, making it look funny.

BTW, the Middle Center alignment wouldn't do for me because, as you said, the numbers are misaligned that way. This condition would be worse than the lack of whitespace.

So I have gained the power to move to the left, only to lose the ability to move down from the horizontal line separating the rows. To quote Gilda Randner, "It's always something!"

Thanks again for your help. I would have never thought of that on my own.

Regards, Dick [2thumbsup]
 
BP,

New information. The Margin property of the TextBox seems to actually be a better solution than the InputMask because it is in a smaller unit (possibly pixels) that gives a better placement precision. If the alignment is Right (or Auto, in the case of numeric data), a Margin of 10 moves the data just about the right distance from the line for me.

The vertical placement SNAFU may be aided by turning the IntegralHeight property of the TextBox to True. My too-high text went away after I did that, but I wasn't able to get it back by turning it False again (so I can't be sure).

None of that would have worked, however, if I hadn't turned the Sparse property of the column to False, as you suggested.

Thanks again! -- Dick [spin2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top