How to put items of listbox on top in c năm 2024

I'm afraid your'e on the wrong track. You have a great idea, but believe it or not, it may be very difficult to implement. Here is an example of how to go about with it :

http://www.bigresource.com/Tracker/Track-vb-8cAR3xkIJJ/

I personally would have used a ListView, as it already contains that capability


  • July 7th, 2010, 09:31 AM

    Re: Listbox Item "top" position the capability of double clicking to edit the text?

    and yes i will try out the link. i will post on how it goes!

    -
  • July 7th, 2010, 09:38 AM

    Re: Listbox Item "top" position

    How to put items of listbox on top in c năm 2024
    Originally Posted by dageek247

the capability of double clicking to edit the text?

No. The concept of putting a textbox over an item, hence trying to make it editable.

- July 7th, 2010, 02:57 PM

Re: Listbox Item "top" position

He wants the TOP index?

If it can show all 6 rows, it scrolls. Otherwise, it goes to the TOP

Code:

Option Explicit Private Sub Command1_Click() > Dim s%, x As Integer > s = List1.TopIndex > If s < List1.ListCount - 6 Then > List1.TopIndex = List1.TopIndex + 5 > Else > List1.TopIndex = 0 > End If > For x = 0 To List1.ListCount - 1 > If List1.Selected(x) = True Then > List1.Selected(x) = False > End If > Next x > End Sub Private Sub Form_Load() > Dim x% > For x = 0 To 15 > List1.AddItem x + 1 > Next x > End Sub David

How to put items of listbox on top in c năm 2024
CodeGuru Article: Bound Controls are Evil-VB6 2013 Samples: MS CODE Samples CodeGuru Reviewer 2006 Dell CSP

2006, 2007 & 2008 MVP Visual Basic

How to put items of listbox on top in c năm 2024
If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!
How to put items of listbox on top in c năm 2024


July 8th, 2010, 01:20 AM

Re: Listbox Item "top" position

How to put items of listbox on top in c năm 2024
Originally Posted by dglienna

He wants the TOP index?

I doubt, David. It seems as if the OP wants an editable listbox - therefore he / she needs to know each item's top position so that he / she can place a TextBox there.

- July 8th, 2010, 03:08 AM

Re: Listbox Item "top" position

How to put items of listbox on top in c năm 2024
Originally Posted by dglienna

He wants the TOP index?

If it can show all 6 rows, it scrolls. Otherwise, it goes to the TOP ... [/CODE]

(First READ the Thread, then answer. \
********.)

BTT: You could compute the Position where to put the Textbox using TextHeight like this :

Code:

Private Sub List1_DblClick() > Dim nPos As Long > Dim nIndex As Long > nPos = List1.TopIndex > nIndex = List1.ListIndex > Text1.Top = List1.Top + ((nIndex - nPos) * TextHeight("Ag")) > End Sub Last edited by HanneSThEGreaT; July 8th, 2010 at 03:18 AM.

- July 8th, 2010, 03:20 AM

Re: Listbox Item "top" position

OK, your comment about the Americans were really not necessary. This is a public forum, and one thing about public forums is that you have to behave yourself. Next time try to be more tactful before dishing someone's response. You won't like it if you were insulted like that.

Consider this a friendly warning.

How to put items of listbox on top in c năm 2024

Hannes


July 8th, 2010, 03:22 AM

Re: Listbox Item "top" position

I still think that trying to add a textbox onto the listbox ( although a nice idea ) is not really the correct way to go - it adds more overhead, more complications with the design, and is more error prone. It is just my opinion - so I may be wrong

How to put items of listbox on top in c năm 2024

-
  • July 8th, 2010, 04:11 AM

    Re: Listbox Item "top" position

    Glad I was too busy to see it!
    How to put items of listbox on top in c năm 2024

And he has PM's turned OFF! (or did you protect the guilty?) David

How to put items of listbox on top in c năm 2024
CodeGuru Article: Bound Controls are Evil-VB6 2013 Samples: MS CODE Samples CodeGuru Reviewer 2006 Dell CSP

2006, 2007 & 2008 MVP Visual Basic

How to put items of listbox on top in c năm 2024
If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!
How to put items of listbox on top in c năm 2024

-
  • July 8th, 2010, 04:23 AM

    Re: Listbox Item "top" position

    How to put items of listbox on top in c năm 2024
    Originally Posted by dglienna Glad I was too busy to see it!
    How to put items of listbox on top in c năm 2024
    And he has PM's turned OFF! (or did you protect the guilty?) I didn't protect anyone!
    How to put items of listbox on top in c năm 2024
    How to put items of listbox on top in c năm 2024
    Eesh, it seems as if I shouldn't have woken up today..... Tell you both what. I thought this thread was under control ( with my previous post ), but I see now that it will turn ugly, and honestly, there is no place for that in this forum. I'm closing this thread now. Sorry dageek, but it seems you'll have to make a new thread, although you did nothing wrong, it is unfair that this has happened - just because people can't behave

    How to add items in ListBox in C# dynamically?

    How to add Items in ListBox in C#?. Step 1: Create a windows form as shown in the below image: Visual Studio -> File -> New -> Project -> WindowsFormApp.. Step 2: Drag the ListBox control from the ToolBox and drop it on the windows form..

    How to display items in ListBox in C#?

    To insert an item into the list box at a specific position, use the Insert method. To add a set of items to the list box in a single operation, use the AddRange method.

    How to get the selected item of a ListBox in C#?

    If you want to obtain the item that is currently selected in the ListBox, use the SelectedItem property. In addition, you can use the SelectedItems property to obtain all the selected items in a multiple-selection ListBox.

    How to clear ListBox selected items in C#?

    ListBox. ObjectCollection class, and how to clear all item selection using the ClearSelected method. The code first moves the currently selected item in the ListBox to the top of the list. The code then removes all items before the currently selected item and clears all selections in the ListBox.