Making a Class Based on a TableView
Posted
#1
(In Topic #268)
Trainee
Code (gambas)
Posted
Expert

Right click on the form with the table view and 'mouse over' the 'Event' selection in the menu list.
This will show you all the events that are accessible for the form ( works the same with any control as well).
If any events have code already written, they will have a tick mark against them.
Select 'KeyPress' and it should drop you to the editor with the correct syntax to trap key events.
in this case it will be:
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Trainee
That clears things up. I'll give that a go. Thanks.
Posted
Trainee
However, when I tried to instantiate the SearchBox in code using
the sb1_Keypress and sb1_Click and sb1_Save handlers in the form's code don't do anything.
So there is still something I am missing. What else do I need to do when I instantiate a class in code? Thanks.
Posted
Expert

Read some detailed information about how to do that here: http://gambaswiki.org/wiki/dev/gambas
From your initial post, I had thought that you were just creating a helper/toolbox class for a standard TableView as this would be the simplest way. My Bad.
Something to note; You can pass a control ByRef to a class subroutine as a parameter and then act on it as desired.
ie: Set the alignment of the GridView columns ( same as a TableView but not editable )
If the gridview has 3 columns that you want set as: center, center, right, you would pass these parameters.
GridViewSetAlignment("C,C,R",MyGridview)
Code (gambas)
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Trainee
Your earlier advice answered my earlier question perfectly. Events have to have handlers in the form. It is no use having the handler in the class. So obvious. The class holds various subs that you can call upon, but the calling has to be done from event handlers in the form.
I don't expect to ever really need to create an instance of a class from within code. Dragging one onto the form at design time is all I shall use.
I wrote a version of a game once—the commercial version was called "Concentration"—where you turn over cards and if you find a match the pair was removed, trying to remember where matching cards were. A bigger board size showed more "cards", and (this is in Xojo) I made as many instances of the card class as the user asked for. But gridviews show pictures in cells, so it is much easier to have one gridview with 6x10 rows and columns than 6x10 instances of a card class. So instantiating a new class derived from a TableView using code is just for academic interest only. Thanks again. Shall read up on components.
Posted
Regular

I've been going at Gambas heavily for about four months now. My initial assessment is that Component development is unnecessarily cumbersome. Let's leave it at that for now.
If I need something only C can do, I have found writing a shared library to be much easier, and much more productive. If I need something on the forms, the controls that exist have been adequate for all my needs.
I recommend you load and run, then read, the programs I posted in "Programming is supposed to be fun"
Gambas One - Gambas ONE
In the second example, I wrap a class around a form control, which in essence is the same as creating a new control. And yes, the instances (some) are created from code.
Ced
P.S. Quin does seem to have a knack for figuring out what you are actually asking.
.... and carry a big stick!
Posted
Trainee
1 guest and 0 members have just viewed this.


