Irregularity in Display

G

Guest

Hi,
Reg:-VisualBasic .Net -SmartDeviceApplication - Pocket PC
I am using a ListBox to display records from a text file(with extension as
..MST). In the file, each record is stored as a string with fixed width(fixed
number of characters). Each line in the text file consists of one record.
So I am using the readLine() function to read each record and adds it to the
Listbox.
But I am facing some irregularity in Displaying items in listbox. For
example, the first field consists of 20 characters and the second field
consists of 15 characters. I am displaying only those two fields. In all
cases, my data in the first field consists of only 12 characters and the next
8 characters are white spaces. So normally 8 blank spaces should be there
before displaying the next field.
In my case, in the pocket pc, it is not displaying all the 8 blank
characters. Instead, it is just displaying only 5 blank characters.
Whatever blank characters are there in between first and second field(>5),
then it is just displaying only 5 blank spaces. I want the complete blank
spaces in the record to get displayed. i.e., after 12 characters, if it is
blank, then I want 8 blank spaces.
If anybody is ready to read it carefully and answer it, it will be a great
help for me.

Hari
 
A

Alex Feinman [MVP]

I suspect that the spaces are all there but because the font is
proportional, they take less space. Have you tried replacing spaces with
dots and checking what is visible that way?
 
G

Guest

Thank you very much.

Yes, I have filled the blanks with characters such that the following
display occurred.

12345678901234567890abcdefghijklmno 'comment: 20+15 characters
12345678901 abcdefghijklmno '12 +15 chars.2nd field moves 1
place left
12345678901234567890abcdefghijklmno 'normal display

if the characters are less in the first field, then the second field moves
to left accordingly. If I am including one line with 10 + 10 characters,
then the second field moves further left.

Actually I am in need of the following display.

Example

12345abcde
123 abc
1234 abcd
12345abcde
1 abc
12 abcd

Irrespective of the no. of characters in the first field, the second field
must start from the 6th position only(in this example).

Could you please suggest me a suitable solution?

Regards,
Hari
 
A

Alex Feinman [MVP]

There are 3 possible solutions:
1) Ideally you would use a list box with LBS_USETABSTOPS style and tab
character inside your strings. Unfortunately this style can be only set when
creating a listbox and CF does not allow you tio inntercept control creation
2) You can change listbox font to Courier (which is a monospaced font). I do
not remeber off the top of my head if Courier is indeed present on the
device, but it is easy to check
3) You can use listview control with two columns instead of listbox and
split each line of text into two subitems using String.Substring()

Dim item as ListViewItem = new ListViewItem(myString.Substring(0, 15))
item.SubItems.Add(myString.Substring(15))

3 Seems like a best solution to me.
 
G

Guest

Thank You very much for the detailed reply. With the Courier font, it is
giving exact spacing between two fields. Since I want a string of around 350
characters in length, the third option specified by you cant be used in the
program(because i am displaying only 2 fields of around 35 characters),
eventhough it is so good.

I will defenitely get back to you with the results after more testing.

Once again my sincere thanks,

Regards,
Hari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top