1. Patrick Montferrier
  2. PowerBuilder
  3. Wednesday, 3 May 2023 11:00 AM UTC

Hello everyone,

I'm a real begginner with PowerBuilder, so excuse my ignorance, and in addition I'm French, so forgive me my way of expressing myself.

 In a window I would like to create synamically some object like with the code bellow :


integer li_counter, li_y
commandbutton lcb_button


FOR li_counter = 1 TO 5
lcb_button = CREATE CommandButton
lcb_button.Text = "Bouton " + String(li_counter)
lcb_button.Width = 100
lcb_button.Height = 30
lcb_button.X = 10
li_y = 50 + ((li_counter - 1) * 40)
lcb_button.Y = li_y

How to create the button ?????


NEXT

 

I struggle to create the button.

Does someone knows how to do that ?

In advance thank you for your advices.

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 3 May 2023 11:17 AM UTC
  2. PowerBuilder
  3. # Permalink

Use function OpenUserobject instead of CREATE.

But you can't reuse lcb_button variable as in your examle.

This should work:

commandbutton lcb_button, lcb_initial
int li_counter, li_y

FOR li_counter = 1 TO 5
	lcb_button = lcb_initial
	OpenUserobject (lcb_button)
	lcb_button.Text = "Bouton " + String(li_counter)
	lcb_button.Width = 100
	lcb_button.Height = 30
	lcb_button.X = 10
	li_y = 50 + ((li_counter - 1) * 40)
	lcb_button.Y = li_y
NEXT
Comment
  1. Patrick Montferrier
  2. Wednesday, 3 May 2023 11:36 AM UTC
Thank you very much, it works perfectly
  1. Helpful
There are no comments made yet.
Patrick Montferrier Accepted Answer Pending Moderation
  1. Thursday, 4 May 2023 12:48 PM UTC
  2. PowerBuilder
  3. # 1

I created an UserObject in the code above, I would like to replace the commandButton by this UserObject named u_sys_agd.

I struggle to do it.

Does someone knows how to do that ?

In advance thank you for your advices.

Comment
  1. René Ullrich
  2. Thursday, 4 May 2023 13:16 PM UTC
If I understand you right you want to dynamically create visible userobjects on your window?

Just replace "commandbutton" with you userobjects classname ("u_sys_agd") in tzhe example code.
  1. Helpful 1
  1. Patrick Montferrier
  2. Thursday, 4 May 2023 14:12 PM UTC
Thank you René
  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.