Add new entry on Listview's first position

Post

Posted
Rating:
#1 (In Topic #1085)
Trainee
Hi,

Has anyone tries to add a new entry at first position to a Listview? You can use the .Add() method, but it adds only after another entry or at the end of the list:

Code (gambas)

  1.  ' after is a valid key within the Listview or null (at the end)
  2.  lv.Add(mykey, mytext, mypicture, after)
  3.  
If I have 5 entries on the Listview and I will add a 6th entry in front of all other entries, there isn't a method to do this. How I can achieve this?

Best regards
Witchi
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’
Try… :?

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   ListView1.Add("aaa", "aaa", Null, Null)
  4.   ListView1.Add("bbb", "bbb", Null, Null)
  5.   ListView1.Add("ccc", "ccc", Null, Null)
  6.  
  7.  
  8. Public Sub Button1_Click()
  9.  
  10.   ListView1.Add("ddd", "ddd", Null, Null).MoveBefore("aaa")
  11.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
Yeah, that works! Thanks a lot!  8-)
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
What if "aaa" is not the first item?

Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
vuott is in the usergroup ‘Regular’

thatbruce said

What if "aaa" is not the first item?
I suppose like the item with key "bbb" or "ccc" ?

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
Use ListItem.MoveFirst() instead.

ListView1.Add("ddd", "ddd", Null, Null).MoveFirst()
/comp/gb.qt4/_treeview_item/movefirst - Gambas Documentation
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
vuott is in the usergroup ‘Regular’

BruceSteers said

Use ListItem.MoveFirst() instead.
…exactly.

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top
1 guest and 0 members have just viewed this.