1. Paweł Kasperek
  2. PowerBuilder
  3. Wednesday, 13 November 2024 11:45 AM UTC

Hi,

I have defined a DataWindow that exceeds the screen size and form. It is too long. During its validation, when there is an error, I want to position myself in a row that is outside the visible range. I'm using the SetColumn function. Unfortunately, the scroll bar remains at the top of the window and DataWindow. How can I programmatically move the scroll bar to the bottom of the DataWindow (window) to show the selected row?

Regards,

Pawel

John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 13 November 2024 14:32 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Pawel -

You do not need to re-position the vertical scroll bar. Instead, tell the DataWindow control which row you want to be able to see via the ScrollToRow() method, and let it determine what scrolling (if any) is needed:

* * * Edited to remove unnecessary SetRow method call. * * *

// Optional: Temporarily suspend re-painting of the DataWindow (this can reduce flicker).
dw_1.SetRedraw(False)

// Make row 723 visible within the DataWindow control and make it the current row.
dw_1.ScrollToRow(723)

// Optional: Highlight row 723.
dw_1.SelectRow(0,False)  // Turns highlighting for ALL rows off.
dw_1.SelectRow(723,True) // Turns highlighting on for row 723.

// Optional: Set the current column to the one that contains the validation error.
dw_1.SetColumn("customer_id") // For example...

// Optional: Re-enable live display of the DataWindow's contents.
dw_1.SetRedraw(True)

Best regards, John

Comment
  1. Miguel Leeuwe
  2. Wednesday, 13 November 2024 15:51 PM UTC
Hi John,

Just a small detail: There's no need to do a SetRow() after having done a ScrollToRow().

regards
  1. Helpful 1
  1. John Fauss
  2. Wednesday, 13 November 2024 22:23 PM UTC
Thank you, Miguel! That's what I get for replying in a hurry. I have edited/corrected the snippet of code.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.