[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Data event of TableView


On Wednesday, November 13th, 2024 at 14:58, Bruce Steers <bsteers4@xxxxxxxxx> wrote:

> I'm finding using a GridView/TableView Data event to be good for some things but just not for others.
> Mostly because it triggers too often, like you say, on Enter and many other instances.
> Much like a Controls Draw event.
> The more you try to do in a Data or Draw event it seems the more cpu hungry your program becomes due to the uncontrollable frequency of the event call.

I use a lot of GridView/TableView Data events and they seem to do the job well.
But as you say, in certain circumstances they can be tricky and a pain in the ass.

II added a counter to a debug line in the Data event just to show me how often Data event is triggered.
Just going over the TableView and back generated over 100 Data event triggers, for just 17 records from a result set.
Leaving it open for a minute and now and then going over the TableView with mouse, resulted in over 5000 Data event triggers in less that, say 2 minutes.

Anyway monitoring the triggering of several events by adding some debug text telling me it in what order all got triggered kind of helped to give some insight.
Fiddling with the order I do stuff in the Data event, some testing, more fiddling, rearranging, deleting and adding and I finally have it working, somehow.

I added a counter to check when all records where handled (so in the TableViewL) by the Data event,.
Once that was achieved I set a Private Boolean to true, for preventing the code to set the recommendations to run again and again on each Data event trigger.

> My latest GambasProcWatch program initially used a Data event but i found it triggered way too often,
> so i just converted it to not use Data event and fill the GridView manually only when i wanted it to.
>
> The traditional old loop...
>
> Inc TableViewL.Rows.Count
> TableViewL[TableViewL.Rows.Max,0].Text = "blah

> Perhaps in this case it might be better to just not use Data event? then you are free to trigger updates when YOU want.

I was thinking about that as well, as mostly (almost always) I only need the result read into the GridView/TableView to show the user. And this only needs to happen once.The continuous triggering of Data event when no new data is being delivered is kind of strange, just takes up cpu cycles.

> Respects
> BruceS

gbWilly
[Gambas3 for Debian](https://gitlab.com/gbWilly/gambas3-debian-repository)

>

References:
Data event of TableViewgbWilly <gbWilly@xxxxxxxxxxxxxx>
Re: Data event of TableViewBruce Steers <bsteers4@xxxxxxxxx>