Page 1 of 1

ListView.Editable, how does it work?

Posted: Wednesday 9th May 2018 5:39am
by computermouth
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/Column ... tml#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!

Re: ListView.Editable, how does it work?

Posted: Wednesday 9th May 2018 1:58pm
by cogier
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.
hListView As ListView

Public Sub Form_Open()
Dim siCount As Short

Me.Arrangement = Arrange.Vertical
Me.Padding = 5
hListView = New ListView(Me) As "ListView1"
hListView.Expand = True
hListView.Editable = True

For siCount = 1 To 10
  hListView.Add(Str(siCount), "Hello ComputerMouth " & Str(siCount))
Next

End

Public Sub ListView1_Click()

hListView.Current.Rename

End
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.

Re: ListView.Editable, how does it work?

Posted: Saturday 12th May 2018 10:11pm
by computermouth
Oh, awesome. Thanks cogier!

That's certainly much less to upkeep over the modal dialog change I had been writing.