[Gambas-user] does listview.item.selected=true do same as listview_click?

Stephen Bungay sbungay at ...981...
Tue Apr 1 07:50:29 CEST 2008


richard terry wrote:
> On Tue, 1 Apr 2008 03:38:12 pm jbskaggs wrote:
>> I noticed with my perpetual file problems- that I needed to track down each
>> step of the program.
>>
>> I discovered that every time listview.item.selected=true occurred it had
>> the same affect as if I clicked on it- because it ran listview_click every
>> time it occured.
>>
>> IN my ignorance and misunderstanding of the doc I thought it meant only to
>> highlight the list.item.
>>
>> Am I understanding that properly now? listview.item.selected=true does same
>> as listview_click?
> 
> The list_select event seems to be triggered as soon as the user clicks on a 
> list and has selected a row, however the row he clicked on is not necessarily 
> matched by the internal pointer to the lists data.
> 
> If you set the item to selected it just means the the current item is the one 
> in the list you have selected, and in this event I've just moved the current 
> internal pointer of the list to match what the user has selected on the 
> screen. (.movecurrent).
> 
> If there was no code attatched to the list_click event, nothing would happen.  
> What you do with the click event is up to you.
> 
> At least that's my experience, but others may correct me.
> 
> 
> 
> 
>> JB SKaggs

   Clicking on a listview fires the listview click event, it also sets 
the selected property to True. Normally the programmer would not have a 
need to programatically set the selected property to True, which is not 
to say it can't be done,.. but begs the question "should it be done".
   If the user clicks on an item in a listview it sets that item to a 
selected state and it will also set that item as the current item. The 
following code can be pasted into a blank form.. add a button, a 
listview, and a text area, keep the names of these controls to their 
defaults.

' Gambas class file

Public Sub Button1_Click()
   PopulateList
End


Public Sub ListView1_Click()
   TextArea1.Text = ListView1.Item.Selected & " " & ListView1.Item.Text 
& " " & ListView1.Current.Key
End


Private Sub PopulateList()
     With ListView1
        .Add("A", "A")
        .Add("B", "B")
        .Add("C", "C")
        .Add("D", "D")
    End With

End

   Click the button and the list populates. Click on any item in the 
list and the text area will display the Selected State, the Text, and 
the Key (which in this case will be the same as the text).

Steve.
> 
> 
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 





More information about the User mailing list