[Gambas-user] Chronic columnview Woes

Tobias Boege taboege at ...626...
Wed May 8 09:25:49 CEST 2013


On Wed, 08 May 2013, Richard Terry wrote:
> Hi List,
> 
> Hoping someone, maybe Benoit can take the time to read this and comment.
> 
> I've been programming in gambas now for a number of years, and as the 
> regulars on the list know Ian Haywood and I have been working on EasyGP, 
> a medical records project.
> 
> For historical reasons I've done much of the work on my old 5 year 
> laptop running an ancient version of kubuntu 9.0, though I have managed 
> to keep gambas3 relatively up to date.  I've had various versions of 
> kubuntu running on my office network running easygp, form 10-11-12 and 
> had varying problems which I'll describe below with columnviews and 
> using them.
> 
> More recently I put Linux Mint Nadia onto a newish laptop (i7 
> quadcore/nvidia) and have been doing alot of development work on that 
> because it is fast.
> 
> Now the problem.
> 
> Throughout my program to display data, I tend to use columnviews, the 
> contents of which I load from an underlying collection (zero based 
> collection members). Clicking on the list should give me the key to the 
> columnview item and hence the collection member
> 
> e.g
> 
> Dim letter as collection
> 
> The subroutine would pull in all the letters from the backend as the 
> letters collection and load them sequentially into the columnview say 
> cvwLetters.
> 
> Now when the user clicks on a cvwLetters row you would expect this code:
> 
> letter = letters[cvwLetters.item.key] to give the appropriate member of 
> the letters collection which it does.
> 
> However, lets say I want to popup a menu of the letters collection:
> 
> If I right mouse click on the list to bring up the menu the  
> cvwLetters_Menu event triggers, but if one inspects the cvwLetters 
> control itself in the IDE, the cvwLetters.item.key is null, however the 
> cvwletters.selected[0] does contain the value one would expect to be in 
> the cvwLetters.item.key.
> 
> I've tried doing e.g cvwLetters.movecurrent() before popping up the 
> menu, this does not seem to make much difference.
> 
> Also I've a chronic problem trying to generate a columnview click event 
> in code, with a similar outcome to the above - the item.key is not set
> 
> Anyone had problems with this, or could give me a simple explanation or 
> example which does work?
> 

At least I remember that we had problems with this control when we prepared
an article about it (doesn't seem to be published yet) because it has three
ways to show you a 'current' element - different ones. I hope someone will
CMIIW!

- Current  : the currently *selected* element in the control; the Key
             property is the Current's key;
- Item     : only an internal, logical cursor, has nothing to do with what
             the user points at; actually, my tests showed that, at least
	     inside ColumnView_Click(), Item is the same as Current but not
	     outside of it, e.g. when clicking on an external Button! So
	     don't use it to represent the element the user has selected;
- Selection: array of all graphically selected elements; especially useful
             for Mode = Select.Multiple.

So in your case I would use Current or Key - or, if you can select multiple
elements, Selection for the keys.

Regards,
Tobias




More information about the User mailing list