Thread: tab is the key

  1. #1
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377

    Angry tab is the key

    I have a string
    Code:
    sprintf(string,"%s - %s", name, lastname);
    I'm using font where width of all characters are not the same, just like here :
    mmmmmmm
    lllllll
    I have to write a list of names in a ListBox. When i do this this problem occurs :
    lmm - sdlkfsdf
    mmm - sdlfkjsfd
    lll - sfkdjsdlf
    lml - slkdfjdf
    So basicly i can use "Courier New",
    Code:
    lmm - sdlkfsdf
    mmm - sdlfkjsfd
    lll - sfkdjsdlf
    lml - slkdfjdf
    but i don't want to. I have heard somewhere about a TAB.
    So how to use a tab in a string. You know just like '\n', so whats the tab symbol
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    tab is '\t'
    Kurt

  3. #3
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    No it's not // tryed that, not working...
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  4. #4
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    It shure is. Youre propably talking about windows and that is not displying the tab- character unless you set the tab-positions ( don't know how to do that )
    Kurt

  5. #5
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Quote Originally Posted by ZuK
    It shure is. Youre propably talking about windows and that is not displying the tab- character unless you set the tab-positions ( don't know how to do that )
    Kurt
    prehaps your right

    Just look how crappy this font looks :
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    sprintf("%10s");
    will set a minimum string length of 10 chars. It will align on the right; to align it on the left, use "%-10s". But this still won't work if you're using a serif etc. font.

    You can't easily get columns to line up with serif fonts. I would use Courier New or Courier.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Quote Originally Posted by dwks
    Code:
     to align it on the left, use "%-10s". But this still won't work if you're using a serif etc. font.
    I figured that out years ago.
    The problem is that i want to align my text with serif, arial, ...
    All the strings are the same size, that's not a problem
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    The problem is that i want to align my text with serif, arial, ...
    You could use different table cells.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Quote Originally Posted by dwks
    You could use different table cells.
    yes i thought about that...
    But it's not simple as it seems.

    I have a listbox
    so if i create two listbox with diffrent strings, the second listbox should scroll as the first.
    And if i select an item in the first listbox, the second should do that too.
    But what if i select an item in second, or scroll second.
    And i'm not planning to use two strings, those two are just for example...
    So imagine 5 list boxes, one next to other, ...
    too complicated.

    I want to do it this way.
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM