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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to move a value of a cells in a

Status
Not open for further replies.

ahmed1973

Programmer
Jan 29, 2013
42
DZ
how to move a value of a cells in another one in the same grid (foxpro)
 
What exact feature do you mean?

Programmatically, automatic? Or do you want to allow users to copy & paste?

A Grid is not an excel sheet, but surely a user can select a cell, copy it's value, select another cell and paste, if the destination cell also is the same field type.

But a grid displays a database table / cursor, it's not an excel sheet, each column can only contain the typ of values it's defined for.

Bye, Olaf.
 
yes it's a grid i have column that contains a field "monttc" i'd like to click on the desired line and move it programmaticaly to another column that i add it with
THISFORM.Grid1.AddColumn(3)
 
my grid displays a database table of two field "date" and "monttc
 
You can't add a column to a grid without having a cursor field to be displayed as it's controlsource. You first have to think about the data table or cursor and let it have the fields you want to display.

Bye, Olaf.
 
Ahmed,

As Olaf suggested, to add a column to a grid, you first must decide which field to map it to in the underlying cursor or table. You then call the grid's AddColumn method, then set its ControlSource to that the field in the cursor or table. However, that's not the usual way to do it. It's more common simply to set the grid up in the first place so that it shows all the columns, by setting the ColumCount property.

Either way, once you've got the grid set up, you can arrange for the user to copy the value from one cell to another. To do so, you reference the fields in the underlying table. So, in this case, the value to be copied is simply the contents of your Monttc field (in the current record).

To copy this value to another column, place that value in the field that correspons to new column (again, in the current record).

So, if the new column is named X, the following code is all you need:

REPLACE X WITH Monttc

You would then need to either refresh the grid, or simply set focus to it, in order for the new value to appear.

Hope this makes sense.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
but i am trying it i can add a column to my grid but it is momentary not permanent.until now its ok with me
wha i need is to put the value that i select to the added column
 
A grid doesn't work this way, a grid needs an underlying source of data, typically a DBF or a cursor alias. A column has no cells as textboxes you can set a value to. In fact a grid only has each control of a row once, all other rows than the active row are merely drawn and if you click into them they get the active row. But there is only one text1 control in each column. That's even true, if you set a column's sparse property to .F.

If you need this to work without also adding a column to the underlying table then you have to use an activex control replacement, many of them rather work by really having a control for each cell which can store a value on it's own.

Bye, Olaf.
 
but i am trying it i can add a column to my grid but it is momentary not permanent

Since it has already been explained to you that a Grid does not work that way, maybe we should be asking you - Why do you want to have a Temporary/Momentary Column in your Grid?

If we know what you are trying to accomplish (other than how it might appear visually), we might be able to help you achieve your goal in another manner.

Good Luck,
JRB-Bldr
 
In fact, you can add a temporary column to a grid. You call the AddColumn method to add it, and the DeleteColumn method to delete it. But, as the others have said, that's not something you would normally do.

Tell us what you overall goal in - in particular, why you feel you need to show the same value in two different columns - and we will try to suggest ways of achieving it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
thank u, like i have said to u before that my table has two fields "date" and "monttc",my goal is to display these two fields in a grid and I'd like to : when i click on a line in this grid column "monttc" it will deplace in another empty column.the objectif is to make a maturity to a subscriber who want to pay his debt (water bill )by periode,its mean divide his debt.

ahmed.
 
If you want to display the calculated value in another column, why do you need to ADD that column?

Why can't you have that column exist ALL the time and be displayed ALL the time with a value of 0 and populate it when the application needs to do so?

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top