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!

Manually Insert data into a grid.

Status
Not open for further replies.

bcoats

Programmer
Jun 20, 2001
49
US
I may be trying to use the wrong control here and if so please let me know. What I am trying to do is this. I need to manually populate a grid with values for the user to make some choices. I dont have the data in a recordset or anything, but I like the format of the grid for this purpose. Is there any way to do set the data that shows in the grid manually and then to read those values back out? Sorry if this is really obvious, it has been a long week.

BCoats
 
If I am understanding correctly you could simply create your own CURSOR and add the values to that, then bind the cursor to the grid?

eg

in the INIT of the form or somehwere appropriate:

Code:
CREASTE CURSOR MyCursor ( MyField C(10 )
INSERT INTO MyCursor VALUES ( 'Choice1' )
INSERT INTO MyCursor VALUES ( 'Choice2' )

ThisForm.ReGrid() && method to be created

then in the REGRID method:

Code:
WITH THISFORM.grdMyGrid

.RECORDSOURCE = 'MyCursor'
.Column1.CONTROLSOURCE = 'MyField'
THISFORM.REFRESHFORM()

ENDWITH

Then when the use click on the value in the grid simply reference the cursor for the appropriate value. Is this what you're after?


I like work. It fascinates me. I can sit and look at it for hours...
 
well, I was actually setting the recordsource to a cursor, the problem is that when you do that. the grid automatically sets itself to read only and the user cannot select the things in the way I want them to. Say for instance that I want col 1 to hold 'Cat', 'Carrot', & 'Calcium' and then col 2 to have a combo box with values to select for a matching game with values 'Animal', 'Mineral', & 'Vegetable'. If I set the first values into a cursor and populate the combobox with the second the grid will not alloe the selection to take place. I need to be able to populate values directly into the grid (and read them back out) if possible.

Or is there another control that would work better?

Thanks.

BCoats
 
If you're using CREATE CURSOR, the grid shouldn't be read-only. If you're creating the cursor with SELECT, make sure to add the READWRITE keyword at the end.

Tamar
 
Is there any way to do set the data that shows in the grid manually and then to read those values back out? Sorry if this is really obvious, it has been a long week.

As the others have told you, you can create a cursor to use as the grid's RecordSOurce. However, the form's init() it too late. You will have far fewer problems if you create the cursor in the form's Load().




Marcia G. Akins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top