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!

Dynamic Datawindow

Status
Not open for further replies.

2good2btru

Programmer
May 1, 2001
17
AE
hi
If i get a reference to a datawindow.....Can i dynamically find out its columns and the datatype each is holding......
 
By using the dwcontrol.SetColumn(column) function which sets the current column in a DataWindow control or DataStore and returns 1 if it succeeds and -1 if an error occurs. If column is less than 1 or greater than the number of columns, SetColumn fails. Also using the dwcontrol.GetColumnName( ) function which obtains the name of the current column.

So all you need to do is set a loop to start at column 1 until the SetColumn function returns a -1 and get every column name for the SetColumn function that returns a 1:

Int li_column = 1
Ls_column_name

Do until dwcontrol.SetColumn(li_column) < 0
Ls_column_name = dwcontrol.GetColumnName( )

Li_column++
loop

to get the column type you will need to use the objectname.ColType property, and you already have the datawindow and column name so it will look like this:

ls_coltype = dwcontrol.Describe(ls_col_name + &quot;.ColType&quot;)

so put everything together and it should look like this

Int li_column = 1
Ls_column_name
String ls_coltype

Do until dw_1.SetColumn(li_column) < 0
Ls_column_name = dw_1.GetColumnName( )
ls_coltype = dw_1.Describe(ls_col_name + &quot;.ColType&quot;)
Li_column++
loop

Hope this helped.

Regards

Tentacle
 
Nice logic.......
Theres another logic which I tried,.. looping thru the array which Object.datawindow.Objects returns.......
colname_t signifies the header text and the rest are all columns..... so i get all the columns and then as u specified.....coltype gives me the datatype.....
But have to admit....urs was a smart one....
Thanks
 
This is actually an extremely inefficient and essentially wrong approach.
Look up Column.Count DataWindow object property in help.
You do a describe on this property, cast it and set your loop for it.
In the loop you do a describe for .ColType property.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top