Results 1 to 6 of 6

Thread: question about listBox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Israel
    Posts
    79

    Post

    i make a listCox, and into it i add stuff from databse file,

    question: how can i make a kind of headline to the listBox, make it like a table with two or more columns, i want one column from the dataFile to be displayed in one column of the listBox, and another column in the data file, in another column in the listBox

    how can i do that ?

  2. #2
    New Member
    Join Date
    Jun 1999
    Location
    dharmapuri,tamil nadu,India
    Posts
    3

    Post

    Want to create a simple list box that shows several fields of data? The columns property of the list box does not do this, but you can use this function to do it.

    Public Const LB_SETTABSTOPS As Long = &H192
    Public Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Any) As Long
    Public Sub DoTabs(lstListBox As ListBox, TabArray() As Long)
    'clear any existing tabs
    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
    'set list tabstops
    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, _
    CLng(UBound(TabArray)), TabArray(0))
    End Sub
    First, set up the columns:

    Dim Tabs(2) as Long
    Tabs(0) = 0
    Tabs(1) = 100
    Tabs(2) = 200
    DoTabs List1, Tabs
    Then, add your items:

    List1.AddItem "John" & vbTab & "Percival" & vbTab & "Content Editor"
    List1.AddItem "James" & vbTab & "Limm" & vbTab & "Senior Editor"


    ------------------

  3. #3
    New Member
    Join Date
    Jun 1999
    Location
    dharmapuri,tamil nadu,India
    Posts
    3

    Post

    Want to create a simple list box that shows several fields of data? The columns property of the list box does not do this, but you can use this function to do it.

    Public Const LB_SETTABSTOPS As Long = &H192
    Public Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Any) As Long
    Public Sub DoTabs(lstListBox As ListBox, TabArray() As Long)
    'clear any existing tabs
    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
    'set list tabstops
    Call SendMessage(List1.hWnd, LB_SETTABSTOPS, _
    CLng(UBound(TabArray)), TabArray(0))
    End Sub
    First, set up the columns:

    Dim Tabs(2) as Long
    Tabs(0) = 0
    Tabs(1) = 100
    Tabs(2) = 200
    DoTabs List1, Tabs
    Then, add your items:

    List1.AddItem "John" & vbTab & "Percival" & vbTab & "Content Editor"
    List1.AddItem "James" & vbTab & "Limm" & vbTab & "Senior Editor"


    ------------------

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Israel
    Posts
    79

    Post

    for some reason this doesnt work, i wanted the listbox to be like a dbgrid, only without the grid. - if it even possible.

  5. #5
    New Member
    Join Date
    Jun 1999
    Location
    Dharmapuri,Tamil Nadu, India
    Posts
    5

    Post

    Hi,
    I did a small mistake. Replace list1 by lstListBox and put the following statements into a module

    Public Const LB_SETTABSTOPS As Long = &H192
    Public Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Any) As Long
    Public Sub DoTabs(lstListBox As ListBox, TabArray() As Long)
    'clear any existing tabs
    Call SendMessage(lstListBox.hWnd, LB_SETTABSTOPS, 0&, ByVal 0&)
    'set list tabstops
    Call SendMessage(lstListBox.hWnd, LB_SETTABSTOPS, _
    CLng(UBound(TabArray)), TabArray(0))
    End Sub

    Declare the following statement in General Declaration of a form

    Dim Tabs(2) as Long

    Then put the following statements into form_load event

    Tabs(0) = 0
    Tabs(1) = 100
    Tabs(2) = 200
    DoTabs List1, Tabs

    List1.AddItem "Vikraman" & vbTab & "Parthiban" & vbTab & "Aishwarya"
    List1.AddItem "Suresh Babu" & vbTab & "Thiyagarajan" & vbTab & "Ganesh"

    then execute and get the result whatever you expect.

    Hint: -Add a list control into your form
    -Size of array tabs mention that how many columns you are going to add

    Bye!

    ------------------

  6. #6
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    1h$®ÊØØ@’@îÂæ@ÂÄØÊ@èÞ@ÊÜÆäòàè@æÞÚÊèÐÒÜÎ@ÂÜÈ@ÈÊÆäòàè@Òè@Â ØæÞB
    BB@¬Êäò@ÆÞÞØ@àäÞÎäÂÚX’@îÒØØ@ÐÊØà@òÞê@ÈÊìÊØÞàÊ@Òè@ÒÌ@òÞê @îÂ
    ÜèZøZ@êäÎÐ@ZøZöÎäÒÜúöÆÞÞØúöæÚÒØÊútîÒÜÖtöÊÊÖúöÊòÊæ úö
    äÌÂÆÊúöæÞèúöÌäÞîÜúöÚÂÈúö~~~ú
    ^7*
    Email: [email protected]
    Website: http://www.hurgh.org/

    Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows

    C, C++, PHP, VB6, ASP, VBScript, JavaScript

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width