0

I have a datawindow. And there I have an entry. I want to add a new entry, with rbuttondown, but it doesn't work. How can i do that? I wrote this, but it's wrong...

IF row > 0 THEN
    //This.SetRow(row)
    This.SelectRow(0, FALSE)
    This.SelectRow(row, TRUE)
    //this.ScrollToRow(row)
    parent.TriggerEvent("ue_agregar")
END IF

Thanks!

XLD_a
  • 195
  • 1
  • 4
  • 16

2 Answers2

1

To insert a new row you need to use the following function...

ll_row = This.InsertRow(0)

The function returns the row it inserted. You can then use this to scroll or select the new row.

  • Yes, but i use rbuttondown event. i want to press right click, then "New", and after that to insert a new entry. I just want to see the previous entry as well. – XLD_a Apr 07 '17 at 03:07
  • My problem is that when i press right click, it appears a menu with "Copy", "Paste", "Cut" options, and after that when i press left click it appears "New". It's a strange behaviour and i don't know why. I just want to press right click and then "New". – XLD_a Apr 07 '17 at 05:59
1

You need to define the menu with your 'New' option which should then trigger the insertrow method and whatever other code you wish to execute.

You display the menu via the PopMenu method like this (From the PowerBuilder help):

If the menu is associated with the window If the menu is currently associated with the window, you can simply call the PopMenu function.

The following statement in a CommandButton script displays m_help as a pop-up menu at the current pointer position, assuming menu m_help is already associated with the window:

m_help.PopMenu(PointerX(), PointerY())

If the menu is not associated with the window If the menu is not already associated with the window, you must create an instance of the menu before you can display it as a pop-up menu.

The following statements create an instance of the menu m_new, then pop up the menu m_new at the pointer location, assuming m_new is not associated with the window containing the script:

m_new   mymenu
mymenu = create m_new
mymenu.PopMenu(PointerX(), PointerY())
Matt Balent
  • 2,337
  • 2
  • 20
  • 23