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

"tab" feature used for spacing text 1

Status
Not open for further replies.

lunaclover

Programmer
Joined
Jun 22, 2005
Messages
54
Hi -
I know in VB6 there was something you could do in order to line text up if it were in a textbox, listbox, etc. So if you had two columns of data you could say something like:

listbox.items.add("Summer ", <tabfeature> , "a season")
listbox.items.add("Fall" , <tabfeature>, "a season")

so that the "a season" would line up together. I know that is a bad example but hopefully you get the idea.

I have been trying to count spacebar hits and that obviously doesn't work in lining anything up. Does anybody know about this feature and if I can use it in VB.net?

Thanks!
Luna
 
I've spent the last 2 weeks against a brick wall called Crystal Reports. Turned out if you are building a deployment package in VS 2k2 with CR XI, the CR msm will bomb if the output filename is over 17 characters.

I hate brick walls.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
How I love my sharpshooter.

brick wall this week: css and asp.net for mobile devices.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Okay earthandfire - THANK YOU so much. The problem was that I was using a listbox, not a listview control. So your explanation was totally lost on me and I got frusterated (newly developed personal problems are getting the best of me, I don't usually give up so easy - and I really appreciate your encouragement. Really.)
I tried your code - it's perfect. But I tried adding two more columns so I have a total of four - I added them in the columns properties but is there something I need to change on this code too?
Code:
Private Sub LVAddItem(ByVal item As String, ByVal subitem As String, ByVal subitem2 As String, ByVal subitem3 As String)

        Dim itm As New ListViewItem(item)
        itm.SubItems.Add(subitem)
        ListView1.Items.Add(itm)
        itm = Nothing

    End Sub
besides adding subitem2 and subitem3 like I did, or is this wrong? I still only see two columns when I run it, even though I have
LVAddItem("8", "25.7", "1", "2HT04501025")

it just shows 8 and 25.7.. I tried manipulating areas of your code but it was squiggling lining my additions and saying "Overload resolution failed because no accessible 'Add' accepts this number of arguments" - I am not sure where to add it to make it know there are more columns it is supposed to show.

Okay - thanks again!! So much.



 
Glad your back.

Since there are only four columns, then hard coding is probably the easiest way:

Code:
 Private Sub LVAddItem(ByVal Item As String, ByVal SubItem1 As String, ByVal SubItem2 As String, ByVal SubItem3 As String)

    Dim itm As New ListViewItem(Item)
    itm.SubItems.Add(SubItem1)
    itm.SubItems.Add(SubItem2)
    itm.SubItems.Add(SubItem3)
    ListView1.Items.Add(itm)
    itm = Nothing

  End Sub

  Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

     LVAddItem("8", "25.7", "1", "2HT04501025")
     ...
     ...

  End Sub

Hope this helps.
 
I clicked submit too soon.

I meant to add, that for each subitem you need:

itm.SubItems.Add(subitemX)


so your changes were almost spot on.
 
That helps tons and it works perfectly. Thank you so much I am so glad it works!

Have a great labor day week-end! I just found out Monday is a holiday for us.. (they looked at me strangly and told me I needed to get out and mingle more often..) but i'm too enraptured with my program! Aah!

: )
Luna
 
Brilliant. Here in the UK we had a Bank Holiday, Monday just gone - so its work for me on Monday - but enjoy your day off [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top