Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some columns in a grid is read-only even when set to false and enable is true 1

Status
Not open for further replies.

gryff15

Programmer
Sep 21, 2016
47
PH
I have two cursors, a parent and child.
Parent has textboxes while child has grid.
The problem is some columns in the grid of the child are read-only and I can't make it editable except for a numeric field and datefield.
Code:
Thisform.container1.grid1.ReadOnly = .F.
Thisform.container1.grid1.Column10.Sparse = .F.
Thisform.container1.grid1.Column10.Enabled = .T.
For lnCountCol = 1 To lnTotalCol
	lnColNo = "column"+Alltrim(Str(lnCountCol))
	Thisform.container1.grid1.&lnColNo..ReadOnly = .F.
	Thisform.container1.grid1.&lnColNo..Enabled = .T.
Endfor

I have no problem with the parent textboxes because they are editable using SetAll.
For the child, I tried grid setall textboxes readonly .F. and enable = .T., still not working.
Please see attached image.

- gryff15 -
 
 https://files.engineering.com/getfile.aspx?folder=5adf65cb-8e72-4a9f-a6d4-5dd715c37c34&file=Screenshot_2022-06-23_234920.png
The whole GRID is readonly. That is why columns are too, no matter what you do.
BTW you can access columns through Coluimns property of the Grid
Code:
For lnCountCol = 1 To lnTotalCol
    Thisform.container1.grid1.Columns(lnCountCol).ReadOnly = .F.
    Thisform.container1.grid1.Columns(lnCountCol).Enabled = .T.
Endfor

Borislav Borissov
VFP9 SP2, SQL Server
 
The grid readonly is set to False by default. I also hardcoded in Init to set it false but it doesn't work.
Thank you for the tip on Columns property though.

- gryff15 -
 
How do you define the cursors? They might be read only.

Are you aware of READWRITE, NOFILTER, or what FILTER CURSORs are and the implications they all have and your possibilities for updatable views or CAs?

Chriss
 
Hmm,

if ControlSource is expression, then column is read only always.
 
Hi Chris,
I created cursor:
Code:
Create Cursor parent (;
	CODE C(10) Not Null,;
	NAME C(50),;
	BIRTHDATE D Not Null,;
	AGE N(3) Not Null))
Create Cursor child (;
	CODE C(10) Not Null,;
	NAME C(50),;
	BIRTHDATE D Not Null,;
	AGE N(3) Not Null))
Then SQLConnect to tmpcursors
scatter memvar, insert into parent&child from memvar
I'm not aware of nofilter & filter cursors.

Hi mJin,

My Grid init has control source.
e.g. This.&lnColNo..ControlSource = "Alltrim(name)"


- gryff15 -
 
gryff15 said:
.ControlSource = "Alltrim(name)"
Well, there is your problem, an expression is one way - readonly, as mJindrova already pointed out. Use name here, and it becomes editable. You can use column.Format="T" to trim away spaces instead.

Chriss
 
Thank you. The removal of alltrim made it editable. One more thing, I can't find a way to insert a new record in the grid.
I have an Add button:
Go bottom
Apppend blank
....grid.column.text1.setfocus()
, does not go to new line. Only focuses to first record.

- gryff15 -
 
Well, after APEND BLANK you are on the new record. All you'd need to do is Thisform.Grid1.Setfocus().

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top