Normally when a datawindow or report is retrieved and there are no rows, you are presented with a blank datawindow. This can be disconcerting to users, especially if they need to insert a row. To get around this we have added a piece of text to the blank datawindow informing the user that there are no rows. This text is made visible if there is no rows and invisible if there are rows. The resize event is used to keep the text centrally located.
To achieve this you must first create a userobject based on a datawindow (which you should have done already anyway).
In the constructor event, create the datawindow text control.
string ls_modify_string
string ls_error_string
long ll_x, ll_y
ll_x = (This.Width - 357) / 2
ll_y = (This.Height - 57) / 2
ls_modify_string = 'Create text(band=foreground alignment="0" ' &
+ 'text="No Rows Found" border="0" color="0" ' &
+ 'x="' + String(ll_x) + '" y="' + String(ll_y) + '" ' &
+ 'height="57" width="357" name=no_rows_found ' &
+ 'font.face="Arial" font.height="-8" font.weight="400" ' &
+ 'font.family="2" font.pitch="2" font.charset="0" ' &
+ 'background.mode="1" background.color="553648127" visible="0")'
ls_string_string = Modify(ls_modify_string)
In the resize event, keep the text control centered within the
datawindow
long ll_x, ll_y
ll_x = (This.Width - 357) / 2
ll_y = (This.Height - 57) / 2
This.Modify('no_rows_found.X="' + String(ll_x) &
+ '"no_rows_found.Y="' + String(ll_y) + '"')
After a retrieve, insert, or delete you need to call this code as either a function or a user event.
This will set the visibility of the the text control dependent on the number of rows.
string ls_modify_string, ls_error_string
If (This.RowCount() = 0) Then
ls_error_string = This.Modify('no_rows_found.Visible="1"')
Else
ls_modify_string = 'no_rows_found.Visible="0"'
ls_error_string = Modify(ls_modify_string)
End If