0

I have a VST using TriStateChecking. This is connected to a database table, so when the user checks a node, its checked field is updated in the database. I would like this to be invisible to the end user; that is no 'Save' button.

I am currently using the OnChecked() event to update the database. The problem is when checking large number of nodes, it essentially executes #CheckedNodes SQL update statements. What i would like to do is capture/be notified when all the tristatechecking is complete so i can simply scan the tree and construct one SQL update statement.

Is there an event i could use once all tristatechecking has completed?

Simon
  • 9,197
  • 13
  • 72
  • 115
  • What you mean by all tristatechecking has completed? There isn't such a posibility to check multiple nodes at once in virtualstringtree IIRC. If you are checking multiple nodes in your procedure or function, then you can use a list to store your checked nodes as i pointed out in my answer. – Linas Mar 08 '11 at 10:52
  • I'm not sure, if that's what you want, but if you wish to run your SQL update after user set all check boxes from undefined state to the defined one, you can store just the undefined check state count. You'll simply set this variable to node count after loading. And in the OnChecked event you'll decrease this variable and if you reach 0, you just iterate through the tree, build and run your SQL statement. –  Mar 08 '11 at 12:00

3 Answers3

2

No, the iteration is the only way to do it. Even CheckedCount property do it in this way.

1

Just have an internal list where you could store checked nodes and onChecked event update the list. When checking large number of nodes, just iterate through your list and construct SQL statement.

Linas
  • 5,485
  • 1
  • 25
  • 35
  • This may work, but im really after an point in time when i know when all the nodes have completed checking. Seems this may not exist. – Simon Mar 08 '11 at 19:34
  • The OnChecked event is triggered when check state is changed. So why don't you simply use some variable which will be by default the total count of your nodes and in the OnChecked event you just decrease its value. When you reach 0, you can be sure that all of your nodes change their states. –  Mar 09 '11 at 09:30
0

Just doing some tests, but it looks like i can simply use the OnMouseUp() event. Should have probably checked before, oops.

Simon
  • 9,197
  • 13
  • 72
  • 115
  • Yes, of course. You can use OnMouseUp, which triggers OnChecked (or more precisely DoCheckClick) just as you find out. But the OnMouseUp will trigger wherever you click on the node. The OnChecked event fires at mouse up only if you release your mouse button over the same node check box as you pressed. So if you are looking for the event which fires after check state change, use the OnChecked. The check state change IS COMPLETED there. –  Mar 08 '11 at 11:49
  • 3
    Don't use the mouse event, at least not by itself. You'll miss the nodes that get checked through other means, such as the keyboard. – Rob Kennedy Mar 08 '11 at 15:13
  • Good point rob, didnt think of that. I will have to reconsider. – Simon Mar 08 '11 at 19:32