Login

Welcome, Guest. Please login or register.

September 07, 2025, 09:10:29 pm

Author Topic: Text-box alignment  (Read 1444 times)  Share 

0 Members and 1 Guest are viewing this topic.

Yendall

  • Victorian
  • Forum Leader
  • ****
  • Posts: 808
  • Respect: +38
Text-box alignment
« on: August 05, 2012, 06:49:50 pm »
0
I'm having an issue with my programming. What I am trying to do is read a text file into a two dimensional array, split using deliminators (","), and display the information in a sort of "column, rows" presentation via Text-Box.

The problems lies with how a Text-Box is traditionally formatted, and I am ending up with something like this (don't mind the Mexican food, my teacher gave me that brief)



The code behind my display button is as follows:
Code: [Select]
        Dim count As Integer
        For count = 1 To p
            txtDisplay.Text += Food(count).PadRight(20) & " " & TableNo(count) & " " & SpecReq(count) & " " & Confirmed(count) & vbCrLf
        Next
        For count = 1 To p
            lstFood.Items.Add(Food(count))

        Next

Basically what i'm trying to achieve is the .PadRight(20) for all variables so I can have an even spacing to emulate rows and columns, but obviously because the names of the meals are different lengths and the SpecReqs are different lengths etc, a PadRight(20) will not do anything but make it more messy than it already is.
Is there a way to format a textbox so it automatically aligns text without messy spacing?
« Last Edit: August 05, 2012, 06:57:28 pm by Yendall »
2013 - 2016: Bachelor of Computer Science @ RMIT
2017 - 2018: Master of Data Science @ RMIT
ΟΟΟΟ
VCE '12: | English | I.T: Applications | I.T: Software Development | Music Performance Solo |  Further Mathematics | Studio Arts |

paulsterio

  • ATAR Notes Legend
  • *******
  • Posts: 4803
  • I <3 2SHAN
  • Respect: +430
Re: Text-box alignment
« Reply #1 on: August 05, 2012, 06:58:40 pm »
0
You do realise, apart from Lucinda Console, most fonts are not evenly spaced, for example, an "i" is narrower than an "n" - thus there's no way you can do what you want to do really :P

Yendall

  • Victorian
  • Forum Leader
  • ****
  • Posts: 808
  • Respect: +38
Re: Text-box alignment
« Reply #2 on: August 05, 2012, 07:00:32 pm »
0
You do realise, apart from Lucinda Console, most fonts are not evenly spaced, for example, an "i" is narrower than an "n" - thus there's no way you can do what you want to do really :P
Yes I realise that, that's why it's so damn annoying. I just thought you could set up invisible break points to indicate where text finishes and starts.
My teacher seems to believe that displaying information like that 'isn't messy if it works'. But no, the reality is, it's f*cking messy.
2013 - 2016: Bachelor of Computer Science @ RMIT
2017 - 2018: Master of Data Science @ RMIT
ΟΟΟΟ
VCE '12: | English | I.T: Applications | I.T: Software Development | Music Performance Solo |  Further Mathematics | Studio Arts |

paulsterio

  • ATAR Notes Legend
  • *******
  • Posts: 4803
  • I <3 2SHAN
  • Respect: +430
Re: Text-box alignment
« Reply #3 on: August 05, 2012, 07:03:28 pm »
0
It will be impossible to work because there is no way for you to measure a width of a word.

For example:
wwwww
iiiii

Both contain the same number of characters, which is the only thing you can measure, but have clearly different widths, so it is impossible to actually pad something like this.

My advice is to just create two textboxes side by side, one with "Tacos...etc." and the other with "1 Gluten Free Y...etc."

It would just look nicer overall.

Yendall

  • Victorian
  • Forum Leader
  • ****
  • Posts: 808
  • Respect: +38
Re: Text-box alignment
« Reply #4 on: August 05, 2012, 07:11:10 pm »
0
Yeah padding isn't an option at all, which makes me wonder why I was even told to use it to solve this issue in the first place.

The listbox on the left side of the program is just created through this code:
Code: [Select]
        For count = 1 To p
            lstFood.Items.Add(Food(count))

        Next

So if I set up four listboxes, I could just code it like:
Code: [Select]
        For count = 1 To p
            lstFood.Items.Add(Food(count))

        Next
        For count = 1 To p
            lstTableNumber.Items.Add(TableNo(count))

etc. etc.

The problem that now lies is that this is meant to be created for a mobile device (U4O1) and I thought that crowding the screen with text boxes would be a problem, as it's supposed to emulate a touch screen. But than again, I could be looking too far into it, if it's an iPad for example, users could easily navigate between multiple textboxes due to it's dimensions ( 7.75 inches tall by 5.82 inches wide [1024x768])

From your experiences, did your program successfully utilise the "portability/phone/tablet" specification? or was it more marked on how you utlised data structures, sorting, arrays, linear searches etc?
2013 - 2016: Bachelor of Computer Science @ RMIT
2017 - 2018: Master of Data Science @ RMIT
ΟΟΟΟ
VCE '12: | English | I.T: Applications | I.T: Software Development | Music Performance Solo |  Further Mathematics | Studio Arts |

Yendall

  • Victorian
  • Forum Leader
  • ****
  • Posts: 808
  • Respect: +38
Re: Text-box alignment
« Reply #5 on: August 05, 2012, 07:30:04 pm »
0


List-boxes are beautiful things.
2013 - 2016: Bachelor of Computer Science @ RMIT
2017 - 2018: Master of Data Science @ RMIT
ΟΟΟΟ
VCE '12: | English | I.T: Applications | I.T: Software Development | Music Performance Solo |  Further Mathematics | Studio Arts |