Page 1 of 1

Selecting a Datagrid column using a variable

Posted: Fri Nov 25, 2011 12:14 pm
by DukeUK
I just can't get this to work.

I'm trying to get the contents of a datagrid cell from a column, where I use a variable to define the actual column.

This is the problem I'm having:

put 2 into tnumbera
put quote & "Col" & tnumbera & quote into tcola
put theDataA[tcola]

theDataA is the line data of a datagrid

If I use put theDataA["Col2"] ..... it returns the right value

but if I use put theDataA[tcola] ....... it doesn't return anything

Any idea what I am doing wrong ?

Kev

Re: Selecting a Datagrid column using a variable

Posted: Sun Nov 27, 2011 11:54 pm
by Zryip TheSlug
DukeUK wrote:I just can't get this to work.

I'm trying to get the contents of a datagrid cell from a column, where I use a variable to define the actual column.

This is the problem I'm having:

put 2 into tnumbera
put quote & "Col" & tnumbera & quote into tcola
put theDataA[tcola]

theDataA is the line data of a datagrid

If I use put theDataA["Col2"] ..... it returns the right value

but if I use put theDataA[tcola] ....... it doesn't return anything

Any idea what I am doing wrong ?
Hi Kev,

I think the problem should be on the line:

Code: Select all

put quote & "Col" & tnumbera & quote into tcola
Col2 is the name of the column in the datagrid. By quoting tcola, you will search for a column "Col2" in the datagrid. That's a bit different. ;)

Code: Select all

put 2 into tnumbera
put "Col" & tnumbera into tcola
put theDataA[tcola]
Note the existence of the GetDataOfLine or GetDataOfIndex functions in the datagrid API, for getting the content of a cell:
http://lessons.runrev.com/s/lessons/m/d ... or-Column-

Re: Selecting a Datagrid column using a variable

Posted: Mon Nov 28, 2011 10:56 pm
by DukeUK
Many thanks

Yes without the quotes it all works fine.

Kev