|
Home > Archive > Programming with dBASE > July 2005 > Grid Location and Entering numeric data
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 |
Grid Location and Entering numeric data
|
|
| Ross Wyborn 2005-07-14, 8:23 pm |
| These are two picky little problems I have and wonder if there is any way to
fix them.
Firstly, is there a way to anchor the rowset in a grid so that the first
record is at the top while the last record is selected (using row select)?
If I go form.rowset.last() the other records scroll off the screen.
Secondly, when entering a number in a numeric entryfield is there a way to
clear the zero? If you don't tab into the entryfield you often end up
entering 20 instead of 2 etc. Is there a method using onselect to clear the
entryfield?
Thanks for reading this.
Ross Wyborn
| |
| Ken Mayer [dBVIPS] 2005-07-14, 8:23 pm |
| Ross Wyborn wrote:
> These are two picky little problems I have and wonder if there is any way to
> fix them.
> Firstly, is there a way to anchor the rowset in a grid so that the first
> record is at the top while the last record is selected (using row select)?
> If I go form.rowset.last() the other records scroll off the screen.
That's the way that grids work. They scroll up and down through the data.
> Secondly, when entering a number in a numeric entryfield is there a way to
> clear the zero? If you don't tab into the entryfield you often end up
> entering 20 instead of 2 etc. Is there a method using onselect to clear the
> entryfield?
Check the article in the Knowledgebase on working with form controls,
there's a discussion of issues regarding numeric fields.
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
| |
| Ross Wyborn 2005-07-14, 8:23 pm |
| Hi Ken,
I checked your notes in knowledgebase. It says "If the user clicks
on the entryfield with the mouse, the cursor will appear where they
clicked." The selectall property does not effect this. What I would like to
do is have it selectAll when the user clicks on the entryfield. Is this not
possible somehow?
Thanks.
Ross Wyborn
| |
| Todd Kreuter [dBVIPS] 2005-07-14, 8:23 pm |
| "Ross Wyborn" <rosswyborn@shaw.ca> wrote in message
news:e7%23RJZNiFHA.1796@news-server...
> I checked your notes in knowledgebase. It says "If the user clicks
> on the entryfield with the mouse, the cursor will appear where they
> clicked." The selectall property does not effect this. What I would like
to
> do is have it selectAll when the user clicks on the entryfield. Is this
not
> possible somehow?
I posted a routine a couple times here or there for that. Don't have it
handy right now, but can post it tomorrow morning. It basically uses the key
event and API to perform a select all. This can be done for all values, or
just values equal to 0.
Todd Kreuter [dBVIPS]
| |
| Ken Mayer [dBVIPS] 2005-07-15, 7:23 am |
| Ross Wyborn wrote:
> Hi Ken,
> I checked your notes in knowledgebase. It says "If the user clicks
> on the entryfield with the mouse, the cursor will appear where they
> clicked." The selectall property does not effect this. What I would like to
> do is have it selectAll when the user clicks on the entryfield. Is this not
> possible somehow?
Add code in the onGotFocus event that does some keyboard work ...
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
| |
| Ross Wyborn 2005-07-17, 8:23 pm |
| Hi Ken,
I tried this.keyboard("{Home}"). I also tried "End", "Insert", "Delete".
None of these work. Any ideas? What about my other question on selecting the
last record of a rowset while putting the first record on the top of a grid?
Can that be done?
Thanks.
Ross Wyborn
| |
| Ken Mayer [dBVIPS] 2005-07-18, 7:23 am |
| Ross Wyborn wrote:
> Hi Ken,
> I tried this.keyboard("{Home}"). I also tried "End", "Insert", "Delete".
Take a look again. You can combine keyboard commands.
this.keyboard( "{Home}" )
this.keyboard( "{Ctrl}+{End}" )
Or something like that.
> None of these work. Any ideas? What about my other question on selecting the
> last record of a rowset while putting the first record on the top of a grid?
> Can that be done?
No.
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
| |
| Roland Wingerter 2005-07-18, 9:23 am |
| Ross Wyborn wrote:
> Firstly, is there a way to anchor the rowset in a grid so that the
> first record is at the top while the last record is selected (using
> row select)? If I go form.rowset.last() the other records scroll off
> the screen.
--------
Which version? I don't see that behaviour in dBASE PLUS 2.5.
Roland
| |
| Ken Mayer [dBVIPS] 2005-07-18, 9:23 am |
| Roland Wingerter wrote:
> Ross Wyborn wrote:
>
>
> --------
> Which version? I don't see that behaviour in dBASE PLUS 2.5.
If you have a form that has a grid showing only 10 rows of a 100 row
table (datalinked properly), and you start with the first row at the top
of the grid, if you issue form.rowset.last(), you will not see the first
row of the table ... (or any of the first ten rows). This is working as
it should.
What he would like, from the sounds of it, is the ability to lock in a
row or set of rows that don't move ...
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
| |
| David Kerber 2005-07-18, 11:23 am |
| In article <25BYZi6iFHA.1796@news-server>, dbase@_nospam_golden
stag.net
says...
> Roland Wingerter wrote:
>
> If you have a form that has a grid showing only 10 rows of a 100 row
> table (datalinked properly), and you start with the first row at the top
> of the grid, if you issue form.rowset.last(), you will not see the first
> row of the table ... (or any of the first ten rows). This is working as
> it should.
>
> What he would like, from the sounds of it, is the ability to lock in a
> row or set of rows that don't move ...
That's not how I interpret it. To me, it sounds like if he issues .last
(), that row should be at the bottom of the grid window, so the 9 rows
previous to the last would be showing, rather than having the last row
be at the top of the grid and no others visible. If that's a correct
interpretation, then I agree that it would be nice to see...
--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
| |
| Todd Kreuter 2005-07-18, 11:23 am |
|
Ross Wyborn wrote:
>
> None of these work. Any ideas?
Forgot to follow up on this. Following is one of the samples I
previously posted. This particular example will replace the value on the
first key stroke if no part of the value is selected. It can be modified
to only perform the replace when the value is zero.
--
Todd Kreuter [dBVIPS]
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
| |
| Ken Mayer [dBVIPS] 2005-07-18, 1:23 pm |
| David Kerber wrote:
> In article <25BYZi6iFHA.1796@news-server>, dbase@_nospam_golden
stag.net
> says...
>
>
>
> That's not how I interpret it. To me, it sounds like if he issues .last
> (), that row should be at the bottom of the grid window, so the 9 rows
> previous to the last would be showing, rather than having the last row
> be at the top of the grid and no others visible. If that's a correct
> interpretation, then I agree that it would be nice to see...
>
If that's what he means, then sure. But that would require a wishlist
request (which may or may not be in the system -- I don't recall at this
point <g> ).
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
| |
| Roland Wingerter 2005-07-18, 1:23 pm |
| David Kerber wrote:
> To me, it sounds like if he issues
> .last (), that row should be at the bottom of the grid window, so the
> 9 rows previous to the last would be showing, rather than having the
> last row be at the top of the grid and no others visible. If that's
> a correct interpretation, then I agree that it would be nice to see...
-------
The behaviour you describe is exactly what I see in the turnkey demo below.
Roland
// Create file
set database to
if not file("myfile.dbf")
create table myfile(;
field1 boolean, field2 char(10), field3 char(10),field4 char(10))
use myfile
generate 20
Endif
use
** END HEADER -- do not remove this line
//
// Generated on 18.07.2005
//
parameter bModal
local f
f = new gridrowsetlastForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class gridrowsetlastForm of FORM
with (this)
height = 18.7273
left = 29.2857
top = 0.0
width = 63.7143
text = ""
endwith
this.MYFILE1 = new QUERY()
this.MYFILE1.parent = this
with (this.MYFILE1)
left = 54.0
top = -0.0455
sql = 'select * from "myfile.DBF"'
active = true
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.myfile1.rowset
rowSelect = true
height = 13.0
left = 2.0
top = 2.0
width = 59.0
endwith
this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_O
NCLICK
height = 1.0909
left = 26.0
top = 16.5
width = 15.2857
text = "Go to last row"
endwith
this.rowset = this.myfile1.rowset
function PUSHBUTTON1_onClick
form.rowset.last()
return
endclass
| |
| Ross Wyborn 2005-07-18, 1:23 pm |
| Hi Ken,
I am using version 2.5. What I had was a grid the showed about 10
records but was srolling off the sreeen on entering even the second record.
However, I have solved the problem. I had a requery(), rowset.refresh() and
a refreshControls(). If I issue the last() statement after these it works
OK. I can see all the records and the last is selected. So that is great.
Also I solved the entering numeric problem with the following in the
ongotfocus event:
this.keyboard("{Del}")
It works fine and should be added to all numeric entryfields. I havn't tried
it but should work for spinboxes as well. When I tried it ealier I used
"Delete" instead of "Del".
Thanks for your assistance on these problems.
Ross Wyborn
"Ken Mayer [dBVIPS]" < dbase@_nospam_golden
stag.net> wrote in message
news:twsfNI8iFHA.1768@news-server...
> David Kerber wrote:
>
> If that's what he means, then sure. But that would require a wishlist
> request (which may or may not be in the system -- I don't recall at this
> point <g> ).
>
> Ken
>
> --
> /(Opinions expressed are purely my own, not those of dataBased
> Intelligence, Inc.)/
>
> *Ken Mayer* [dBVIPS]
> /Golden Stag Productions/
> dBASE at goldenstag dot net
> http://www.goldenstag.net/GSP
> http://www.goldenstag.net/dbase
| |
| Ross Wyborn 2005-07-18, 1:23 pm |
| Hi Todd,
Thanks for the example. However, I solved the problem with some help
from Ken in a much more easy way. I added the following to the onGotFocus
event.
this.keyboard("{Del}")
"Right Arrow" also works but gave me an annoying keyboard beep
Thanks again
Ross Wyborn
| |
| Todd Kreuter 2005-07-18, 8:23 pm |
| Ross Wyborn wrote:
>
> Thanks for the example. However, I solved the problem with some help
> from Ken in a much more easy way. I added the following to the onGotFocus
> event.
> this.keyboard("{Del}")
Okay. Although, I don't agree with modifying the value by simply giving
focus to the control.
--
Todd Kreuter [dBVIPS]
| |
| Ken Mayer [dBVIPS] 2005-07-18, 8:23 pm |
| Ross Wyborn wrote:
> Hi Ken,
> I am using version 2.5. What I had was a grid the showed about 10
> records but was srolling off the sreeen on entering even the second record.
> However, I have solved the problem. I had a requery(), rowset.refresh() and
> a refreshControls(). If I issue the last() statement after these it works
> OK. I can see all the records and the last is selected. So that is great.
> Also I solved the entering numeric problem with the following in the
> ongotfocus event:
> this.keyboard("{Del}")
> It works fine and should be added to all numeric entryfields. I havn't tried
> it but should work for spinboxes as well. When I tried it ealier I used
> "Delete" instead of "Del".
> Thanks for your assistance on these problems.
I agree with Todd that deleting or modifying a value in an entryfield
just by giving it focus is really a bad idea ...
Ken
--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/
*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
| |
| Todd Kreuter 2005-07-19, 9:23 am |
|
Roland Wingerter wrote:
>
> David Kerber wrote:
> -------
> The behaviour you describe is exactly what I see in the turnkey demo below.
Using you demo, the last row does appear on the last row of the grid.
However, this is not true for all cases. I forget the circumstances, but
there are cases where you will get the last row appearing as the first
row of the grid. It might be the active index, a masterRowset/Fields
link, etc...
--
Todd Kreuter [dBVIPS]
| |
| Roland Wingerter 2005-07-19, 11:23 am |
| Todd Kreuter wrote:
> Roland Wingerter wrote:
>
> Using you demo, the last row does appear on the last row of the grid.
-------
Thanks for the confirmation.
> However, this is not true for all cases. I forget the circumstances,
> but there are cases where you will get the last row appearing as the
> first row of the grid. It might be the active index, a
> masterRowset/Fields link, etc...
------
Yes, I remember having seen this behaviour, but can't reproduce it. I set an
active index on field2, but it did not make a difference.
Roland
| |
| Todd Kreuter 2005-07-19, 1:23 pm |
|
Roland Wingerter wrote:
>
> Yes, I remember having seen this behaviour, but can't reproduce it. I set an
> active index on field2, but it did not make a difference.
I tried to reproduce as well, with no luck.
--
Todd Kreuter [dBVIPS]
| |
| Ross Wyborn 2005-07-19, 8:23 pm |
| Hi Ken,
The entryfield is not datalinked and after it is used (by using a
pushbutton) I set the value back to 0. So I can't think of a situation where
it can go wrong.
Ross Wyborn
|
|
|
|
|