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.
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)
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.
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)
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.
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.
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)
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.