PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD20] Table control select a row automatically after initializing
[WD20] Table control select a row automatically after initializing
Iniciado por guest, 03,dic. 2015 00:14 - 10 respuestas
Publicado el 03,diciembre 2015 - 00:14
After the table control is initialized, sometimes, table control will select the first record in the table and run "Selecting a row of TABLE_xx" code.
I don't want table to select anything after initializing.
Is it there any way to stop it?
What do I miss?
Publicado el 03,diciembre 2015 - 08:20
Hi Bruce Lee, I am Badr Hari,

In response to your question "What do I miss", you missed the respect to this community, next time start your request with Hi, Hello, Please.
The contributions here are free from people who have many years of hard work, so we owe them a lot of respect.

Please next time consider this.
Publicado el 03,diciembre 2015 - 09:24
Bruce,

This Help page describes the initial state of a Table control:
http://doc.windev.com/en-US/…

You can also use TableSelect and TableSelectMinus to de-select a row as and when required.
Publicado el 03,diciembre 2015 - 15:37
Sorry, Badr,

Next time, I will start with Hi.
Publicado el 03,diciembre 2015 - 16:27
Sadly, I don't think you can stop this event from triggering. There are two situations that trigger this code block: Selecting a row and deselecting a row.

After you initalize your table, I recommend you immediately use TableSelect() and TableSelectMinus() to deselect the row (see my sample code). Then set a variable, such as "isReadyForSelection = true" and check this value inside your "Selecting a row of TABLE_xx".

Keep in mind: Deselecting a row with TableSelectMinus() will trigger another selection event.

// Set Table Row Selection nCurrentRowSelected is int = TableSelect(MySelf) // Is table selected? IF nCurrentRowSelected > 0 THEN // Deselect Table TableSelectMinus(MySelf, nCurrentRowSelected) END // Ready for Selection isReadyForSelection is Boolean = True
// Can rows be selected? IF isReadyForSelection THEN ... END
Publicado el 03,diciembre 2015 - 17:14
Hi Darren,

Thank you!
Publicado el 03,diciembre 2015 - 17:23
Hi Andrew,

Thank you!

Your idea works.

One more question, sometimes, when I click a row in a table, it doesn't trigger "Selecting a row of TABLE_xx" event. Have you ever met this situation?
Publicado el 03,diciembre 2015 - 17:45
If it's already selected the code won't run. For that situation use mouse click event.
Publicado el 03,diciembre 2015 - 17:46
Thank you.
Publicado el 03,diciembre 2015 - 17:59
Thank you, Andrew.

I fixed it.
Publicado el 03,diciembre 2015 - 19:33
It's also useful the property "initialized".

For example, inside the process "On Table Select" you can use:

IF Myself..initialized = false then return

Regards,
José Antonio.