[Gambas-user] TableView Tag Property

Gianluigi bagonergi at gmail.com
Wed Jan 13 17:53:28 CET 2021

Il giorno mer 13 gen 2021 alle ore 15:36 Tobias Boege <taboege at gmail.com>
ha scritto:

> 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
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk

Hi Tobias,

your suggestion works great.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210113/b9e01fa1/attachment.htm>

More information about the User mailing list