PowerBuilder, different DD list values for each row

Source http://www.pbdr.com/pbtips/dw/fltrdddw.htm

Step 1 – declare instance variables

boolean ib_dropdowndropped = False
boolean ib_dropdownredrawn = True

Step 2 – extend the pbm_dropdown event

ib_dropdowndropped = True
ib_dropdownredrawn = False
of_Filter(True)
ib_dropdownredrawn = True

Step 3 – extend the pbm_ncpaint event

If (ib_dropdowndropped And ib_dropdownredrawn) Then
 ib_dropdowndropped = False
 ib_dropdownredrawn = False
 of_Filter(False)
 ib_dropdownredrawn = True
End If

Step 4 – write the of_Filter (boolean ab_switch) subroutine

datawindowchild ldwc
long ll_getitemnumber
string ls_setfilter = ""

If (ab_switch) Then
 ll_getitemnumber = GetItemNumber(GetRow(), "order_status_id")
 If (ll_getitemnumber = 1) Then // cancelled -> cancelled
  ls_setfilter = "(order_status_id = 1)"
 ElseIf (ll_getitemnumber = 2) Then // confirmed -> confirmed
  ls_setfilter = "(order_status_id = 2)"
 ElseIf (ll_getitemnumber = 3) Then // new -> cancelled, new, pending
  ls_setfilter = "(order_status_id = 1) or (order_status_id = 3) or
(order_status_id = 4)"
 ElseIf (ll_getitemnumber = 4) Then // pending -> cancelled, confirmed,
pending
  ls_setfilter = "(order_status_id = 1) or (order_status_id = 2) or
(order_status_id = 4)"
 End If
End If

GetChild("order_status_id", ldwc)
ldwc.SetFilter(ls_setfilter)
ldwc.Filter()

Bowerbuilder datawindow autosize problem

You have a datawindow. Datawindow has an Autosize Height set to Details band. You insert a row, set a long string value to some field expecting that field to be auto-sized. And it is, but you don’t see a text as Details band does not auto-size. What to do? Whan way to fix this is to call Sort() somewhere after you set v the value fro the datawindow to refresh and auto-size to take effect. But that does not work all times ( for example … you dont want to sort data now). Another way is to set:

dw.Modify ( ‘DataWindow.Header.Height.AutoSize=yes’)

This will also make datawindow to resize all the bands and auto-size will take effect then.

Calling .NET from PowerBuilder

To call .NET for PowerBuilder best option is to create Class Library in Visual Studio. Sign it. In project properties, Application, Assembly Information…, check “Make assembly COM-Visible”.

Sign it class library (project properties, Signing…).

In project properties, Application, Assembly Information…, check “Make assembly COM-Visible”.

Optional, add these attributes to your class:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId(“ClassLibrary1.Class1”)]

Register created DLL in command lime like:

regasm /tlb “path/to/dll/file.dll” /codebase

Use it from PowerBuilder like:


OLEObject obj

Integer li_rc

obj = CREATE OLEObject
li_rc = obj.ConnectToNewObject("ClassLibrary1.Class1")

IF li_rc < 0 THEN

DESTROY obj MessageBox("Connecting to COM Object Failed",     "Error: " + String(li_rc)) Return

MessageBox("Connecting to COM Object Failed",     "Error: " + String(li_rc)) Return

Return

ELSE obj.ShowMe()END IF

obj.ShowMe()

END IF

To call some web service from this DLL you add service reference and then:

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address =
new EndpointAddress("http://web-service-url");
var client = new ServiceReference1.YourWebServiceClient(binding, address);

var b = client.YourWebServiceMethod();