ListView.Editable, how does it work?

Post Reply
computermouth
Posts: 2
Joined: Wednesday 09th May 2018 5:12am

ListView.Editable, how does it work?

Post by computermouth » Wednesday 09th May 2018 5:39am

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!

User avatar
cogier
Site Admin
Posts: 159
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: ListView.Editable, how does it work?

Post by cogier » Wednesday 09th May 2018 1:58pm

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.

computermouth
Posts: 2
Joined: Wednesday 09th May 2018 5:12am

Re: ListView.Editable, how does it work?

Post by computermouth » Saturday 12th May 2018 10:11pm

Oh, awesome. Thanks cogier!

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest