Page 1 of 1

NULLify field with not-editable DDDW

PostPosted: 16 Jun 2017, 13:39
by Ursego
How to allow user to delete current selection in a not-editable DDDW using the Delete key:

1. Create a user event in the datawindow control mapped to pbm_dwnkey.
2. Put the following code in the event:

Code: Select all
/**********************************************************************************************************************
Dscr:         Allows user to delete current selection in not-editable DDDW using Delete key
***********************************************************************************************************************
Developer:   Michael Zuskin - LinkedIn: http://linkedin.com/in/zuskin
**********************************************************************************************************************/
string   ls_col_name
string   ls_null
long      ll_null
long      ll_row

if key <> KeyDelete! then return

ll_row = this.GetRow()
if ll_row < 1 then return

ls_col_name = this.GetColumnName()
if IsNull(ls_col_name) or ls_col_name = '' then return

if this.Describe(ls_col_name + ".Edit.Style") <> 'dddw' or this.describe(ls_col_name + ".DDDW.NilIsNull") <> 'yes' then return

if Left(this.Describe(ls_col_name + ".coltype"), 4) = 'char' then
   SetNull(ls_null)
   this.SetItem(ll_row, ls_col_name, ls_null)
else
   SetNull(ll_null)
   this.SetItem(ll_row, ls_col_name, ll_null)
end if

return 0