Share this page 

Delete current selection in DDDWTag(s): Datawindow


Create a user event in the datawindow control mapped to pbm_dwnkey. Put the following code in the event:
string ls_columnname
string ls_null
long  ll_null
long  ll_row

// for a dddw,the delete key deletes the current selection(replace by NULL)
if key = KeyDelete! then
 ll_row = this.GetRow()
 if ll_row > 0 then
  ls_columnname = this.GetColumnName()
  if not (IsNull(ls_columnname) or ls_columnname = '') then
   if this.Describe(ls_columnname + ".Edit.Style") = 'dddw' and + &
    this.describe(ls_columnname + ".DDDW.NilIsNull") = 'yes' then
    if left(this.Describe(ls_columnname + ".coltype"),4) = 'char' then
     SetNull(ls_null)
     this.SetItem(ll_row,ls_columnname,ls_null)
    else
     SetNull(ll_null)
     this.SetItem(ll_row,ls_columnname,ll_null)
    end if
   end if
  end if
 end if
end if

return 0