Results 1 to 8 of 8

Thread: create textbox inside of a listbox control

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 1999
    Posts
    52
    The subject pretty much says it all but what I want to do is create a text entry field inside of a list box at the end of the list when a button is clicked. Any help is welcomed. TIA.
    -Adam
    Yahoo!: _eclipsed_
    ICQ:18534929

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    How bout a combo box?

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    just curious, what is the purpose of this?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 1999
    Posts
    52

    Wink

    I don't think it was understood what I was wanting to do. I have a listbox. When a user clicks a command button I want a text box to appear inside the listbox at the very bottom (under the last entry) so that text can be typed. When the user clicks outside of the text box I want the text inside the text box to become the (new) last entry on the list. I suppose the same end result (an new entry at the end of the box) could be achieved using a text box on the form or something like that but I've seen this done and would like to use this method as it's more visual appealling and cuts down on form space used.
    -Adam
    Yahoo!: _eclipsed_
    ICQ:18534929

  5. #5
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    I think I know what you mean, this can be done by using a ListView instead of a ListBox with the LabelEdit property set to Automatic (or Manual if you want to activate is using a command button). It fires the BeforeLabelEdit and AfterLabelEdit events, which you can use to determine if the user has changed the label.

    Good luck!

  6. #6
    Guest
    Use the SetParent API function.


    Code:
    Private Declare Function SetParent Lib "user32" _
    (ByVal hWndChild As Long, ByVal hWndNewParent As _
    Long) As Long
    
    Private Sub Form_Load()
        SetParent Text1.hWnd, List1.hWnd
    End Sub

  7. #7
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Code:
    Private Declare Function SetParent Lib "user32" _
    (ByVal hWndChild As Long, ByVal hWndNewParent As _
    Long) As Long
    
    Private Sub Command1_Click()
        Text1.Visible = True
        Text1.SetFocus
    End Sub
    
    Private Sub Form_Load()
        SetParent Text1.hWnd, List1.hWnd
        Text1.Left = -30
        Text1.Top = List1.Height - Text1.Height - 30
    End Sub
    
    Private Sub Form_Resize()
        List1.Width = Me.ScaleWidth
        Text1.Width = List1.Width
        Me.Height = 3600
    End Sub
    
    Private Sub Text1_LostFocus()
        List1.AddItem Text1.Text, List1.ListCount
        Text1.Visible = False
        Text1.Text = ""
    End Sub
    I just used Matthew's suggestion and tested what you were talking about, hope this is what you needed.
    -Excalibur

  8. #8

    Thread Starter
    Member
    Join Date
    Jun 1999
    Posts
    52

    Cool Suhweet

    Thanks guys...that's exactly what I was after. I hate to sound greedy but can anyone tell me how I can place it right under the last entry so that the textbox will pop-up in the same place that the text in contains will appear after Command1_LostFocus() is called?? Many thanks.
    -Adam

    p.s. If not it's no big deal but if so that would be great.
    -Adam
    Yahoo!: _eclipsed_
    ICQ:18534929

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