Link to home
Start Free TrialLog in
Avatar of azrakdragon
azrakdragon

asked on

Size of a datacolumn

Is there a way to retrieve the size of a datacolumn? I am looping thru the columns of a table in a dataset in order to retrieve the column name and size. Column name is no problem but I cannot get the size. Anyone?
Avatar of gajender_99
gajender_99

grdtable.TableStyles(0).GridColumnStyles(colnumber).Width = 'Your width'
Hi azrakdragon, Why would you want to know that, all columns except the string have a fixed size.
and the string type doesn't support a fixed size.
Avatar of azrakdragon

ASKER

Looping thru a dataset, not a datagrid.
I need to determine the length of ech column that is a string type as a flat file is being created with fixed lengths. It needs to be dynamic without a user having to maintain the lengths of each column but having them set using the size of the field in the table.
Well to only way to do this is loop through your datatable and check the lenght of each string in the column

It would also come in handy for other things like setting the max length of a text box based on the field it is retrieving its value from etc...
Hi RonaldBiemans, If I loop and check the length of each string will the length returned not necessarily be the length defined for the field in the database. i.e. Varchar field of size 50 holds the value "test". The length returned would be 4 instead of 50.
ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi RB, many thanks