[Gambas-user] Question about GridViews

ML d4t4full at gmail.com
Wed Aug 22 20:16:01 CEST 2018


On 22/08/18 14:35, Me wrote:
> On Wed, 22 Aug 2018 17:59:26 +0200
> Rolf-Werner Eilert <rwe-sse at osnanet.de> wrote:
>> Just a question...
>> Is it possible to "attach" or "insert" other elements into a GridView cell?
>> For instance, it might be nice to have a combobox in a GridView. Can I add this to the GridView cell's .Data somehow?
>> I have one program which uses TextLabels and ToolButtons above GridView cells to simulate this to some extend, but I have to make them via arrays of objects and have to control them so that they follow the grid when it's scrolled etc.
>> If they could be pinned to a grid cell, it would be easier to manage.
>> Regards
>> Rolf
> Have a look at the sourrce code for the TableView control. From memory that is what it does to create the "cell editor".
> hth
> b

Long time ago, in a galaxy far far away, I implemented something like
this in VB6.

I guess a new Gambas Control can be created inheriting from GridView,
Textbox and (a collection of) Combo. Make sure the combos are preset to
not allow editing.
The combo collection maps to one combo per combo-bound-column in the
grid: One would set the combo-columns beforehand, and fill these combos
with whatever data is needed.
For example, a combo-column might be "LANGUAGE", and its combo items
would be "ENGLISH", "FRENCH", "SPANISH", "GERMAN", "RUSSIAN", etc.,
while another combo-column could well be "GENDER" and the items "MALE",
"FEMALE", etc.
The Textbox is just one and is there for cell-editing of cells in
non-combo columns.

Then, when the user double-clicks a cell, the control should move and
show either the Textbox (defaulting its text to whatever the cell had),
or the appropriate combo (with the selected index matching the data in
the cell)) from the collection right on top of the target cell, thus
allowing "editing".
TEXTBOX: When ENTER or any arrow key is pressed (or the mouse clicks
away from the textbox, like to another cell), changes are accepted; if
ESC is pressed instead, changes are discarded. Then, hide the textbox.
COMBO: If the selected item changed, update the cell; otherwise cancel
the change. Then hide the combo.

A nice touch I did not implement would be to have a TEXTAREA for
multiline cell data, but that is just nitpicking.

That would be it.



More information about the User mailing list