Home > Archive > Programming with dBASE > December 2005 > Grid - AllowEditing









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 - AllowEditing
eric wu

2005-12-08, 11:23 am

I know I can set grid.AllowEditing = false to block users editing data
in a grid,
but what if I just want to block some columns ( not all columns ) inside
the grid ?

in VDB5.7 I can put a \R to make a single column ReadOnly
form.browse1.fields = "tablename->fieldname\R"

How can I do in DBPlus ?


Les Shewchuk

2005-12-08, 1:23 pm

I don't think you can do it with the grid or any of it's component
properties.

You CAN do it with the field's properties. There is a ReadOnly property for
each field object that can be set. You can reach this either via the
form|query|rowset|fi
elds|FieldArray or via the Form|Grid|Column
Array|Datalink. (field objects may be easy to link to, but are buried fairly
deep in the control Hierarchy)

HOWEVER. Setting it to false will stop all changes to the field. This can
cause problems if you have any program functions that make changes to that
field. You will have to remember to set the field's ReadOnly to false at
the start of these functions and back to true when done.

Les Shewchuk.



"eric wu" <ericwuu@hotmail.com> wrote in message
news:he36GcB$FHA.1232@news-server...
>I know I can set grid.AllowEditing = false to block users editing data
>in a grid,
> but what if I just want to block some columns ( not all columns ) inside
> the grid ?
>
> in VDB5.7 I can put a \R to make a single column ReadOnly
> form.browse1.fields = "tablename->fieldname\R"
>
> How can I do in DBPlus ?
>



Bruce Beacham

2005-12-08, 1:23 pm

eric wu wrote:
> I know I can set grid.AllowEditing = false to block users editing data
> in a grid,
> but what if I just want to block some columns ( not all columns ) inside
> the grid ?


You could set the fields' canChange events to return false when the grid
gets focus, and unset them when the grid loses focus.


Bruce Beacham
Ken Mayer [dBVIPS]

2005-12-08, 8:23 pm

Bruce Beacham wrote:
> eric wu wrote:
>
>
>
> You could set the fields' canChange events to return false when the grid
> gets focus, and unset them when the grid loses focus.


Um, or you could use the readOnly property of the individual fields ... <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/dbase/dBASEBook.htm
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
4m

2005-12-11, 7:23 am


"eric wu" <ericwuu@hotmail.com> a écrit dans le message news:
he36GcB$FHA.1232@news-server...
> I know I can set grid.AllowEditing = false to block users editing data
> in a grid,
> but what if I just want to block some columns ( not all columns ) inside
> the grid ?
>
> in VDB5.7 I can put a \R to make a single column ReadOnly
> form.browse1.fields = "tablename->fieldname\R"
>
> How can I do in DBPlus ?
>
>


You can datalink the grid column with a calculated field with the same value

Etienne Gounon


Zagrijs Venter

2005-12-13, 7:23 am


"eric wu" wrote

>I know I can set grid.AllowEditing = false to block users editing data
>in a grid,
> but what if I just want to block some columns ( not all columns ) inside
> the grid ?
>
> in VDB5.7 I can put a \R to make a single column ReadOnly
> form.browse1.fields = "tablename->fieldname\R"
>
> How can I do in DBPlus ?


Included is a work around. Not perfect, but it does it.

Zagrijs Venter

if not file( "test.dbf" )

create table test;

( Code char(08),;

name char(20),;

address char(30),;

town char(20) )

endif



** END HEADER -- do not remove this line

//

// Generated on 13/12/2005

//

parameter bModal

local f

f = new testForm()

if (bModal)

f.mdi = false // ensure not MDI

f.readModal()

else

f.open()

endif



class testForm of FORM

with (this)

onOpen = class::ONOPEN

height = 11.9545

left = 1.5714

top = 0.5909

width = 102.0

scrollBar = 2 // Auto

endwith



this.TEST1 = new QUERY()

this.TEST1.parent = this

with (this.TEST1)

left = 20.0

top = -0.0455

sql = "select * from test.dbf"

active = true

endwith



this.TXCODE = new TEXT(this)

with (this.TXCODE)

height = 1.0

left = 7.2857

top = 0.4091

width = 9.5714

wrap = false

alignVertical = 2 // Bottom

text = "Code"

endwith



this.EFCODE = new ENTRYFIELD(this)

with (this.EFCODE)

dataLink = form.test1.rowset.fields["code"]

height = 1.0

left = 7.2857

top = 1.5

width = 10.0

endwith



this.GRID1 = new GRID(this)

with (this.GRID1)

onLeftMouseUp = class::GRID1_ONLEFTM
OUSEUP

onMouseMove = {;if this.allowediting;this. allowediting=false;e
ndif}

dataLink = form.test1.rowset

columns["COLUMN1"] = new GRIDCOLUMN(form.GRID1)

columns["COLUMN1"].dataLink = form.test1.rowset.fields["code"]

columns["COLUMN1"].editorType = 1 // EntryField

columns["COLUMN1"].width = 11.4286

columns["COLUMN2"] = new GRIDCOLUMN(form.GRID1)

columns["COLUMN2"].dataLink = form.test1.rowset.fields["name"]

columns["COLUMN2"].editorType = 1 // EntryField

columns["COLUMN2"].width = 24.8571

columns["COLUMN3"] = new GRIDCOLUMN(form.GRID1)

columns["COLUMN3"].dataLink = form.test1.rowset.fields["address"]

columns["COLUMN3"].editorType = 1 // EntryField

columns["COLUMN3"].width = 28.7143

columns["COLUMN4"] = new GRIDCOLUMN(form.GRID1)

columns["COLUMN4"].dataLink = form.test1.rowset.fields["town"]

columns["COLUMN4"].editorType = 1 // EntryField

columns["COLUMN4"].width = 23.8571

with (columns["COLUMN1"].headingControl)

value = "Code"

endwith



with (columns["COLUMN2"].editorControl)

colorNormal = "BtnText/Btnface"

endwith



with (columns["COLUMN2"].headingControl)

value = "Name"

endwith



with (columns["COLUMN3"].editorControl)

colorNormal = "BtnText/Btnface"

endwith



with (columns["COLUMN3"].headingControl)

value = "Address"

endwith



with (columns["COLUMN4"].editorControl)

colorNormal = "BtnText/Btnface"

endwith



with (columns["COLUMN4"].headingControl)

value = "Town"

endwith



height = 7.7727

left = 3.8571

top = 3.1364

width = 94.7143

endwith



this.rowset = this.test1.rowset



function onOpen



local r



r = form.rowset



r.first()



if r.endOfSet

r.beginAppend()

r.fields["code"].value = "12345"

r.fields["name"].value = "Test Name"

r.fields["address"].value = "Test Address"

r.fields["town"].value = "Test Town"

r.save()

endif



return



function GRID1_onLeftMouseUp(
flags, col, row)



if this.currentcolumn == 1

this.allowEditing = true

this.setfocus()

else

this.allowEditing = false

endif



return



endclass


Zagrijs Venter

2005-12-13, 7:23 am

There is obviously no need for the lines "else" and "this.allowEditing =
false" in "function GRID1_onLeftMouseUp(
flags, col, row)" and can be
ommitted.


"Zagrijs Venter" wrote >
> Included is a work around. Not perfect, but it does it.



>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com