ListView.Editable, how does it work?

Post

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

I have a ListView, on which the Editable property is set to True.

I had read this old forum post: http://gambas.8142.n7.nabble.com/ColumnView-Editable-True-td51747.html#a51776

Granted it's ColumnView, but I had hoped it would function similarly. I was hoping that I would be able to double-click to edit a ListView item. I want to be able to rename the entry after it's been created.

I started writing a modal dialogue for a corresponding "Rename" button, but if it's directly supported through the native component, I'd rather use that.

Any tips?

Thanks!
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi computermouth and welcome to the forum.

I had a look at this issue and discovered that you can edit a list item by pressing the [F2] key. If you want to be able to edit by clicking on a list item you need a routine to catch the click event. Put the code below in 'Graphical application' and run it.

Code (gambas)

  1. hListView As ListView
  2.  
  3. Public Sub Form_Open()
  4. Dim siCount As Short
  5.  
  6. Me.Arrangement = Arrange.Vertical
  7. Me.Padding = 5
  8. hListView = New ListView(Me) As "ListView1"
  9. hListView.Expand = True
  10. hListView.Editable = True
  11.  
  12. For siCount = 1 To 10
  13.   hListView.Add(Str(siCount), "Hello ComputerMouth " & Str(siCount))
  14.  
  15.  
  16. Public Sub ListView1_Click()
  17.  
  18. hListView.Current.Rename
  19.  

EDIT: - You can change Public Sub ListView1_Click() to Public Sub ListView1_DblClick() for a double click rather that a single click.

Let us know how you get on.
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
 Oh, awesome. Thanks cogier!

That's certainly much less to upkeep over the modal dialog change I had been writing.
Online now: No Back to the top
1 guest and 0 members have just viewed this.