NULLify field with not-editable DDDW


Link to this posting

Postby Ursego » 16 Jun 2017, 13:39

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
User avatar
Ursego
Site Admin
 
Posts: 143
Joined: 19 Feb 2013, 20:33



Ketones are a more high-octane fuel for your brain than glucose. Become a biohacker and upgrade yourself to version 2.0!



cron
Traffic Counter

eXTReMe Tracker