Op woensdag 13 augustus 2014 07:12:06 UTC+2 schreef
abhishe...@gmail.com:
That's no problem. I felt like it, so I wrote you some sample code:
You can use the Modify() function in PowerBuilder to change settings in datawindows. This would be like changing a setting for a datawindow item in the PowerBuilder editor.
For the itemchanged event on the datawindow, I wrote the following code:
long ll_value
long ll_limit
string ls_previousText
ll_value = Long(data)
ls_previousText = String(dw_1.GetItemNumber(1, 'number'))
if
dwo.name = 'number_typ' then
choose case ll_value
case 1
ll_limit = 10
case 2
ll_limit = 8
case 3
ll_limit = 6
end choose
dw_1.Modify('number.edit.limit = ' + String(ll_limit))
// TODO You'll want to do something with the old value I placed in
// TODO ls_previousText; right now the length limit will be properly
// TODO enforced, but PowerBuilder won't remove the old text for you,
// TODO even if it's too long. So you'll probably want to cut off the
// TODO text in dw_1.number (using Left() or Right()) or just empty
// TODO its value completely.
end if
You can see that based on the radiobutton value you choose, I changed the limit length and modified the datawindow field using the Modify function.
Also pay note to the TODO comments I left behind, as you'll want to do something with a possible value already entered. Below is the entire source code for a test window and test datawindow I created for this sample. Just open the window from somewhere and you'll have some runnable code:
w_test:
forward
global type w_test from window
end type
type cb_1 from commandbutton within w_test
end type
type dw_1 from datawindow within w_test
end type
end forward
global type w_test from window
integer width = 1202
integer height = 872
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_1 cb_1
dw_1 dw_1
end type
global w_test w_test
on w_test.create
this.cb_1=create cb_1
this.dw_1=create dw_1
this.Control[]={this.cb_1,&
this.dw_1}
end on
on w_test.destroy
destroy(this.cb_1)
destroy(this.dw_1)
end on
event open;dw_1.InsertRow(0)
end event
type cb_1 from commandbutton within w_test
integer x = 361
integer y = 624
integer width = 402
integer height = 112
integer taborder = 20
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Kill me :("
end type
event clicked;Close(parent)
end event
type dw_1 from datawindow within w_test
integer x = 37
integer y = 28
integer width = 901
integer height = 396
integer taborder = 10
string title = "none"
string dataobject = "d_test"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type
event itemchanged;long ll_value
long ll_limit
string ls_previousText
ll_value = Long(data)
ls_previousText = String(dw_1.GetItemNumber(1, 'number'))
if
dwo.name = 'number_typ' then
choose case ll_value
case 1
ll_limit = 10
case 2
ll_limit = 8
case 3
ll_limit = 6
end choose
dw_1.Modify('number.edit.limit = ' + String(ll_limit))
// TODO You'll want to do something with the old value I placed in
// TODO ls_previousText; right now the length limit will be properly
// TODO enforced, but PowerBuilder won't remove the old text for you,
// TODO even if it's too long. So you'll probably want to cut off the
// TODO text in dw_1.number (using Left() or Right()) or just empty
// TODO its value completely.
end if
end event
d_test:
release 12.5;
datawindow(units=0 timer_interval=0 color=1073741824 brushmode=0 transparency=0 gradient.angle=0 gradient.color=8421504 gradient.focus=0 gradient.repetition.count=0 gradient.repetition.length=100 gradient.repetition.mode=0 gradient.scale=100 gradient.spread=100 gradient.transparency=0 picture.blur=0 picture.clip.bottom=0 picture.clip.left=0 picture.clip.right=0 picture.clip.top=0 picture.mode=0 picture.scale.x=100 picture.scale.y=100 picture.transparency=0 processing=0 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes print.background=no print.preview.background=no print.preview.outline=yes hidegrayline=no showbackcoloronxp=no picture.file="" )
header(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
summary(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
footer(height=0 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
detail(height=396 color="536870912" transparency="0" gradient.color="8421504" gradient.transparency="0" gradient.angle="0" brushmode="0" gradient.repetition.mode="0" gradient.repetition.count="0" gradient.repetition.length="100" gradient.focus="0" gradient.scale="100" gradient.spread="100" )
table(column=(type=number updatewhereclause=yes name=number dbname="number" )
column=(type=number updatewhereclause=yes name=number_typ dbname="number_typ" values="Num 1 1/Num 2 2/Num 3 3/" )
)
text(band=detail alignment="1" text="Number:" border="0" color="33554432" x="37" y="4" height="64" width="352" html.valueishtml="0" name=number_t visible="1" font.face="Tahoma" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
column(band=detail id=1 alignment="1" tabsequence=10 border="5" color="33554432" x="425" y="4" height="76" width="402" format="[general]" html.valueishtml="0" name=number visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes font.face="Tahoma" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
text(band=detail alignment="1" text="Number Typ:" border="0" color="33554432" x="37" y="140" height="64" width="352" html.valueishtml="0" name=number_typ_t visible="1" font.face="Tahoma" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
column(band=detail id=2 alignment="1" tabsequence=20 border="0" color="33554432" x="425" y="140" height="232" width="306" format="[general]" html.valueishtml="0" name=number_typ visible="1" radiobuttons.columns=1 radiobuttons.scale=no radiobuttons.threed=yes font.face="Tahoma" font.height="-10" font.weight="400" font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" background.transparency="0" background.gradient.color="8421504" background.gradient.transparency="0" background.gradient.angle="0" background.brushmode="0" background.gradient.repetition.mode="0" background.gradient.repetition.count="0" background.gradient.repetition.length="100" background.gradient.focus="0" background.gradient.scale="100" background.gradient.spread="100" tooltip.backcolor="134217752" tooltip.delay.initial="0" tooltip.delay.visible="32000" tooltip.enabled="0" tooltip.hasclosebutton="0" tooltip.icon="0" tooltip.isbubble="0" tooltip.maxwidth="0" tooltip.textcolor="134217751" tooltip.transparency="0" transparency="0" )
htmltable(border="1" )
htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" pagingmethod=0 generatedddwframes="1" )
xhtmlgen() cssgen(sessionspecific="0" )
xmlgen(inline="0" )
xsltgen()
jsgen()
export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )
import.xml()
export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" )
export.xhtml()