|
Home > Archive > Programming with dBASE > October 2005 > Help with Grid entry control
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Help with Grid entry control
|
|
| Brian Frederick 2005-10-27, 9:23 am |
| I'm trying to upgrade a dB2K app to dBase Plus 2.6. I would like to setup
an event (possibly onMouseDown) that on a mouse click determines if the
value in the current grid column is numeric. If the value is numeric and
equal to zero, I would like to move the cursor to the right one space. I
have tried to write such an event using Keyboard "{RightArrow}" but it
doesn't work correctly. I would like to further refine the event to move
to the decimal point on any numeric value. Would someone please offer some
advice or sample code?
Thank you,
Brian
| |
| Todd Kreuter 2005-10-27, 11:23 am |
| Brian Frederick wrote:
>
> I'm trying to upgrade a dB2K app to dBase Plus 2.6. I would like to setup
> an event (possibly onMouseDown) that on a mouse click determines if the
> value in the current grid column is numeric. If the value is numeric and
> equal to zero, I would like to move the cursor to the right one space. I
> have tried to write such an event using Keyboard "{RightArrow}" but it
> doesn't work correctly. I would like to further refine the event to move
> to the decimal point on any numeric value. Would someone please offer some
> advice or sample code?
I have a control called LeftofPoint EntryField which ensures the cursor
starts at the left of point for a numberic entryfield but not a grid
editorControl. I'm pretty sure it can be adapted for editing in the grid
though.
I also have the following example code that forces a select all when a
user starts typing a numeric value in a grid cell. Currently, the demo
will force a select all only when no part of the value is selected (like
when the use clicks into the cell). This behaviour can be changed to
always select all, or only select all when the value is 0, etc...
--
Todd Kreuter [dBVIPS]
*** Copy to GridNum.wfm ****
set database to
if NOT _app.databases[1].tableExists("GridNum")
create table "GridNum" (;
Text Character(10),;
ST Numeric(3,1),;
OT Numeric(3,1),;
DT Numeric(3,1))
insert into "GridNum" values("1st", 0,0,0)
insert into "GridNum" values("2nd", 0,0,0)
insert into "GridNum" values("3rd", 0,0,0)
endif
** END HEADER -- do not remove this line
//
// Generated on 10/05/2004
//
parameter bModal
local f
f = new GridNumForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class GridNumForm of FORM
with (this)
height = 16.0
left = 25.7143
top = 0.0
width = 51.2857
text = ""
endwith
this.QUERY1 = new QUERY()
this.QUERY1.parent = this
with (this.QUERY1)
left = 18.4286
top = 14.2727
sql = 'select * from "GridNum.dbf"'
active = true
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
onOpen = class::Grid_onOpen
dataLink = form.query1.rowset
columns["COLUMN1"] = new GRIDCOLUMN(form.GRID1)
columns["COLUMN1"].dataLink = form.query1.rowset.fields["text"]
columns["COLUMN1"].editorType = 1 // EntryField
columns["COLUMN1"].width = 14.2857
columns["COLUMN2"] = new GRIDCOLUMN(form.GRID1)
columns["COLUMN2"].dataLink = form.query1.rowset.fields["st"]
columns["COLUMN2"].editorType = 1 // EntryField
columns["COLUMN2"].width = 7.1429
columns["COLUMN3"] = new GRIDCOLUMN(form.GRID1)
columns["COLUMN3"].dataLink = form.query1.rowset.fields["ot"]
columns["COLUMN3"].editorType = 1 // EntryField
columns["COLUMN3"].width = 7.1429
columns["COLUMN4"] = new GRIDCOLUMN(form.GRID1)
columns["COLUMN4"].dataLink = form.query1.rowset.fields["dt"]
columns["COLUMN4"].editorType = 1 // EntryField
columns["COLUMN4"].width = 7.1429
colorRowHeader = "Green/BtnFace"
height = 8.0
left = 1.2857
top = 0.6818
width = 42.5714
endwith
this.rowset = this.query1.rowset
function Grid_onOpen
********************
extern CLONG SendMessageN(CHANDLE
, CUINT, CUINT, CLONG) User32 ;
from "SendMessageA"
local i
for i = 2 to 4
this.columns[i].editorControl.onGotFocus =
class::gridEdit_onGo
tFocus
this.columns[i].editorControl.key = class::gridEdit_Key
endfor
endfor
function GridEdit_onGotFocus
********************
********
this.firstKey = false
return
function GridEdit_key(nChar, nPosition, bShift, bControl)
********************
*
if NOT this.firstKey
if SendMessageN(this.hwnd, 0x00B0, 0, 0) = 0
SendMessageN(this.hwnd, 0x00B1, 0, -1)
endif
this.firstKey = true
endif
return true
endclass
| |
| Brian Frederick 2005-10-28, 9:23 am |
| Thanks Todd. This is just what I needed.
> Brian Frederick wrote:
>
> I have a control called LeftofPoint EntryField which ensures the cursor
> starts at the left of point for a numberic entryfield but not a grid
> editorControl. I'm pretty sure it can be adapted for editing in the grid
> though.
>
> I also have the following example code that forces a select all when a
> user starts typing a numeric value in a grid cell. Currently, the demo
> will force a select all only when no part of the value is selected (like
> when the use clicks into the cell). This behaviour can be changed to
> always select all, or only select all when the value is 0, etc...
>
> --
> Todd Kreuter [dBVIPS]
>
>
> *** Copy to GridNum.wfm ****
> set database to
> if NOT _app.databases[1].tableExists("GridNum")
> create table "GridNum" (;
> Text Character(10),;
> ST Numeric(3,1),;
> OT Numeric(3,1),;
> DT Numeric(3,1))
>
> insert into "GridNum" values("1st", 0,0,0)
> insert into "GridNum" values("2nd", 0,0,0)
> insert into "GridNum" values("3rd", 0,0,0)
>
> endif
> ** END HEADER -- do not remove this line
> //
> // Generated on 10/05/2004
> //
> parameter bModal
> local f
> f = new GridNumForm()
> if (bModal)
> f.mdi = false // ensure not MDI
> f.readModal()
> else
> f.open()
> endif
>
> class GridNumForm of FORM
> with (this)
> height = 16.0
> left = 25.7143
> top = 0.0
> width = 51.2857
> text = ""
> endwith
>
> this.QUERY1 = new QUERY()
> this.QUERY1.parent = this
> with (this.QUERY1)
> left = 18.4286
> top = 14.2727
> sql = 'select * from "GridNum.dbf"'
> active = true
> endwith
>
> this.GRID1 = new GRID(this)
> with (this.GRID1)
> onOpen = class::Grid_onOpen
> dataLink = form.query1.rowset
> columns["COLUMN1"] = new GRIDCOLUMN(form.GRID1)
> columns["COLUMN1"].dataLink = form.query1.rowset.fields["text"]
> columns["COLUMN1"].editorType = 1 // EntryField
> columns["COLUMN1"].width = 14.2857
> columns["COLUMN2"] = new GRIDCOLUMN(form.GRID1)
> columns["COLUMN2"].dataLink = form.query1.rowset.fields["st"]
> columns["COLUMN2"].editorType = 1 // EntryField
> columns["COLUMN2"].width = 7.1429
> columns["COLUMN3"] = new GRIDCOLUMN(form.GRID1)
> columns["COLUMN3"].dataLink = form.query1.rowset.fields["ot"]
> columns["COLUMN3"].editorType = 1 // EntryField
> columns["COLUMN3"].width = 7.1429
> columns["COLUMN4"] = new GRIDCOLUMN(form.GRID1)
> columns["COLUMN4"].dataLink = form.query1.rowset.fields["dt"]
> columns["COLUMN4"].editorType = 1 // EntryField
> columns["COLUMN4"].width = 7.1429
>
> colorRowHeader = "Green/BtnFace"
> height = 8.0
> left = 1.2857
> top = 0.6818
> width = 42.5714
> endwith
>
> this.rowset = this.query1.rowset
>
> function Grid_onOpen
> ********************
>
> extern CLONG SendMessageN(CHANDLE
, CUINT, CUINT, CLONG) User32 ;
> from "SendMessageA"
>
> local i
>
> for i = 2 to 4
> this.columns[i].editorControl.onGotFocus =
> class::gridEdit_onGo
tFocus
> this.columns[i].editorControl.key = class::gridEdit_Key
> endfor
>
> endfor
>
> function GridEdit_onGotFocus
> ********************
********
>
> this.firstKey = false
>
> return
>
> function GridEdit_key(nChar, nPosition, bShift, bControl)
> ********************
*
>
> if NOT this.firstKey
> if SendMessageN(this.hwnd, 0x00B0, 0, 0) = 0
> SendMessageN(this.hwnd, 0x00B1, 0, -1)
> endif
>
> this.firstKey = true
>
> endif
>
> return true
>
>
> endclass
| |
| Todd Kreuter [dBVIPS] 2005-10-28, 8:23 pm |
| "Brian Frederick" <b.frederick@comcast.net> wrote in message
news:ZeIlSj82FHA.1352@news-server...
>
> Thanks Todd. This is just what I needed.
You're welcome, Brian.
Todd Kreuter [dBVIPS]
|
|
|
|
|