[Gambas-user] TableView Tag Property

Martin mbelmonte at belmotek.net
Wed Jan 13 20:28:29 CET 2021


I try the _GridView_Cell way using a variable declaration, even using 
properties (with read / write methods also) instead of variables but 
while it is possible to declare the properties or variables and add them 
to the original class, something doesn't quite work.

I'll continue using .wordwarp for now as I can't understand why 
rewriting the class doesn't work.
Thanks for the theory, it will surely serve me in many other opportunities.

Tanks.


El 13/1/21 a las 15:35, Tobias Boege escribió:
> On Wed, 13 Jan 2021, Martin wrote:
>> Hi,
>>
>> Tableview has not Tag property for each cell, but is there some way to add
>> this property to it?
>>
>> The point is that when I click on a cell I want it to change its image to
>> show another state, which is easy using the mousedown event, for example,
>> but when is necessary to save the state data on a support, such as a
>> database where is the info?
>>
>> It seems that there is no place to extract the true or false information.I
>> currently use the .WordWrap property but it's not the right thing to do I
>> guess, .Tag would be the optimal solution.
>>
>> What could be the solution? Change the components [Grid|Table]View ? or ...
>> Made a modified component?
>>
> This is indeed sometimes an inconvenience in Gambas. A Tag property can
> be useful for remembering external information inside a control or any
> object, but that property exists only sporadically.
>
> The clean and proper way around this is to make a new control class.
> Apparently TableView is not made to hold all the information you want
> to associate with a cell. So make a custom control based on TableView,
> which has an internal Array or Collection indexed by the cells which
> stores the additional data and presents a convenient interface to it.
> Look at how TableView.class in gb.form wraps the GridView class to
> add functionality to it.
>
> That is more work than having Benoît add a Tag property and waiting for
> the next stable Gambas version. It may be more work than you want to do.
> Alternatively, here is a hack that I believe should work: TableView is
> essentially a GridView, which is a control implemented in Gambas as of
> some much earlier version of Gambas 3.
>
> A cell in a TableView is of type _GridView_Cell. It is a completely
> ordinary Gambas class (as opposed to a native virtual class if it had
> been implemented in a gb.qt or gb.gtk component, but I digress...).
> This means that you can *extend* the _GridView_Cell class by over-
> riding it in the global symbol table [1].
>
> Basically: add a class named _GridView_Cell to your project and mark
> it Export. Then just add "Public Tag As Variant" inside the class,
> nothing else is needed. You do not have to re-implement the cell or
> copy it over from gb.form; the interpreter will automatically merge
> your version *into* the one from gb.form. This way you replace the
> normal cell class with your extended version all throughout the
> current Gambas process, so everything that uses a _GridView_Cell
> will now transparently have this additional public variable Tag.
>
> I haven't tried it myself, but I think it should work.
>
> Best,
> Tobias
>
> [1] http://gambaswiki.org/wiki/doc/object-model#t21
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210113/44fc28d5/attachment.htm>


More information about the User mailing list