Datagrid colums name ??

G

Guest

Dear all,

I have a datagrid erver control which is bind to a dataset.
How to display as column name custom text instead of database fields name ?

Ex :
Started At instead of START_TIME_COL

thnaks
regards
serge
 
J

joshuacoad

You can go into the DataGrid's Property Builder (right-click on
DataGrid -> Property Builder) and accomplish this. Under the Columns
section, uncheck "Create columns automatically at run time" and then
add each Bound Column, if they are not already there. Under each Bound
Column's properties, you can change the HeaderText property to whatever
you want. Just make sure to leave the DataField property to the field
name in the database.
 
G

Guest

Thanks for your reply
I need to bind datset to datagrid dynamically , so grid column name as well,
so I do not want to you the propertie builder from the IDE.
I rather prefer to code it

If I do that, is there a particular event that I can play with which occurs
just before the grid gets dispay and allows me to change column text and
datbound filed ?

thnaks
 
J

joshuacoad

I don't blame you on not wanting to use the IDE, I prefer not to as
well.

It might be easier to come up with a solution if I knew a little bit
more about what the application is doing, for instance, when you are
collecting the data that determines the column names. One suggestion
would be to use a DataTable instead of a DataSet. Is there a fixed
number of columns and how are you determining what the columns are to
be named? The DataSet does have the following property that maybe you
could use:

oDataSet.Tables(0).Columns(0).ColumnName

You could traverse through the DataSet and change the ColumnName based
on the index, before you bind it to the DataGrid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top