Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27124

VS 2012 Lining up text in a listbox

$
0
0
Hi,

I am entering items in to a listbox, it goes like this:

Name: Qty: Location: Description: Order Code:
Resistor 100 Drawer 4 0603 Resistor 10% 123456

I have text boxes and dropdowns for each field and I am using the MeasureString graphics function to get the width of the text in the textbox.

The max width in the textbox is 280 so I am running a loop adding chr(9) (tabs) each time checking the width until I reach 280, I then add this to the string and add the item to the listbox as above.

The problem I seem to be having is that occasionally if the length is just right it will be a tab short and it doesn't line up.

Here is my code:

Get_Width()

For i4 = 0 To 4 ' Max number of tabs for 280 width

If String_Width.Width <= 228 Then ' 280 less tab width of 52 in Arial 9pt
Temp_String = Temp_String & Chr(9)
Get_Width()


Else
i4 = 4
End If

Next

This should should line up 'Order Code' row perfectly but it doesn't and I can't figure out why.

Any help would be great, thanks.

Viewing all articles
Browse latest Browse all 27124

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>