2
votes

I am building a tool that can outputs certain information from the input.

I have this free form DataWindow with textboxes and a button( button_1 ). Let's say I have a Window Button [ADD] and when clicked will trigger dw_1.InsertRow(0)

The textboxes and button( button_1 ) will multiply according to how many times the ADD button is clicked.

I was planning to add another DataWindow inside the free form DataWindow so that when the button_1 is clicked to whatever row it is. will call dw_2.InsertRow(0) that is inside that DataWindow, this dw_2 DataWindow has textboxes of its own and can have multiple rows inside it.

Is this possible? If yes how do I do this, if not, can you recommend a way on how can I do this.

2

2 Answers

2
votes

In theory you can script a ButtonClicked event in a DataWindow control (e.g. in a window or user object painter), but sending you down this path is not what you really want, from what I can tell. You can't edit data in a nested DataWindow, so the button to insert a row is probably pointless.

It's not clear why you're trying to do this in one DataWindow, but I'd suggest doing this in two DataWindows on a single window (or user object), which might lead you to use a regular commandbutton control on the window instead of in the DataWindow.

Good luck,

Terry.

1
votes

You can accomplish this with either a computed field (which doesn't directly update the database) or with an extra column and some script.

If you use a computed field, the expression would be

CumulativeSum (1 for all)

That will basically add a row number to each row. You can expand on that if you need a non-linear or non-sequential numbering.

If you need to use script, then simply add the math and the SetItem() statements immediately after you call InsertRow(). If you're using a datawindow button with the action of "Insert Row (12)", change that instead to "User Defined (0)" and, like Terry said, put the script in the DataWindow's ButtonClicked event.