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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right Alignment

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi

Is there any way to align the numeric column in list box right hand side?

Thanks

Saif
 
I don't think so. But you can right-align the individual items before adding them to the box.

Code:
lnNumber = < your numeric value >
lcItem = TRANSFORM(lnNumber, "9999")
THISFORM.List1.AddItem(lcItem)

By changing the second parameter to TRANSFORM() ("9999" in my example), you can vary with width and the formatting of the displayed number.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Using Mikes Code, also use a monospaced font (like Courier New) to display digits aligned. I'd always do this for numerical columns in any multi line control.

Otherwise, the listbox has no alignment, neither in general, nor for each single column.

Bye, Olaf.
 
Hi

I am using the following Code:

Code:
Local lcsearch
lcsearch = Upper(Alltrim(This.Value))
Thisform._csearch = m.lcsearch

Select icode As icode,;
     barcode As barcode,;
   full_desc As full_desc,;
      m_code As m_code,;
      s_code As s_code,;
      f_code As f_code, ;
     packing As packing,;
        unit As unit ;
   from icode Where ;
   upper(icode+barcode+full_desc+m_code+s_code+f_code) ;
   like '%'+m.lcsearch+'%' Order By icode Into Cursor junk4

Select junk4
Go Top
DoDefault()
With Thisform.list1
   .RowSource = 'Junk4'
   .RowSourceType = 2
   .ColumnCount  = 8
   .ColumnLines  = .T.  
Endwith

How can I set the picture of packing as stated by Mike in that?

Thanks

Saif
 
Is Packing a numeric field or a character string?

If it's numeric, then change this:

Code:
packing As packing,;

to this:

Code:
packing As TRANSFORM(packing, "99999");

If it's a string, then change it to this:

Code:
packing As PADL(packing, 5);

In each case, adjust the second param (that is, "99999" or 5 in my examples) to suit the number of characters.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike, almost!

It must be expression AS fieldname, not vice versa.

So: ... PADL(packing, 5) as packing

Bye, Olaf.
 
You're right, of course, Olaf. What was I thinking?

Saif, this is what I should have said:

If it's numeric, then change this:

Code:
packing As packing,;

to this:

Code:
TRANSFORM(packing, "99999") AS Packing, ;

If it's a string, then change it to this:

Code:
PADL(packing, 5) AS Packing, ;

In each case, adjust the second param (that is, "99999" or 5 in my examples) to suit the number of characters.


Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
By the way, PADL also works with numeric input eg both PadL(123,5,"0") and PadL("123",5,"0") result in "00123" and the third optional parameter is there to define a padding with leading zeros, if you like.

Bye, Olaf.
 
Lovely, with the combination of Mike (TRANSFORM(packing, "99999") AS Packing,) and Olaf's (monospaced font (like Courier New)) I got my desired result.

Thanks

Saif
 
I typically put labels over the listbox. Does it make sense to have a header in the list? The list only contains the items the user is able to select and list items can be scrolled, if there are more than the listbox can show in parallel. Labels are the easiest solutions, aren't they?

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top